diff options
author | Oleg Nesterov <oleg@redhat.com> | 2017-08-14 23:02:29 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-08-14 23:02:29 +0000 |
commit | 21c588892cd0bcdcaf4ba8eadf389438fb8d6f2e (patch) | |
tree | 2c32de8469176bb5d22489a5c8474957d98f30ec | |
parent | 5153b165e561b4b35cf39d77f65ca86281419482 (diff) | |
parent | 44bd206c1fe6c42f19988dff9664d421de4e5ded (diff) | |
download | v4.4-21c588892cd0bcdcaf4ba8eadf389438fb8d6f2e.tar.gz |
UPSTREAM: kthread: Pin the stack via try_get_task_stack()/put_task_stack() in to_live_kthread() function am: a960dbced9
am: 44bd206c1f
Change-Id: Ie3df0a56ddc3e41f7dc9d96da377905dc21dae32
-rw-r--r-- | kernel/kthread.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c index 698b8dec3074..d9b0be5c6a5f 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -65,7 +65,7 @@ static inline struct kthread *to_kthread(struct task_struct *k) static struct kthread *to_live_kthread(struct task_struct *k) { struct completion *vfork = ACCESS_ONCE(k->vfork_done); - if (likely(vfork)) + if (likely(vfork) && try_get_task_stack(k)) return __to_kthread(vfork); return NULL; } @@ -427,8 +427,10 @@ void kthread_unpark(struct task_struct *k) { struct kthread *kthread = to_live_kthread(k); - if (kthread) + if (kthread) { __kthread_unpark(k, kthread); + put_task_stack(k); + } } EXPORT_SYMBOL_GPL(kthread_unpark); @@ -457,6 +459,7 @@ int kthread_park(struct task_struct *k) wait_for_completion(&kthread->parked); } } + put_task_stack(k); ret = 0; } return ret; @@ -492,6 +495,7 @@ int kthread_stop(struct task_struct *k) __kthread_unpark(k, kthread); wake_up_process(k); wait_for_completion(&kthread->exited); + put_task_stack(k); } ret = k->exit_code; put_task_struct(k); |