aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kthread.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 9eb7fed0bbaa..a84dee265f94 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -52,8 +52,21 @@ enum KTHREAD_BITS {
52 KTHREAD_IS_PARKED, 52 KTHREAD_IS_PARKED,
53}; 53};
54 54
55#define to_kthread(tsk) \ 55#define __to_kthread(vfork) \
56 container_of((tsk)->vfork_done, struct kthread, exited) 56 container_of(vfork, struct kthread, exited)
57
58static inline struct kthread *to_kthread(struct task_struct *k)
59{
60 return __to_kthread(k->vfork_done);
61}
62
63static struct kthread *to_live_kthread(struct task_struct *k)
64{
65 struct completion *vfork = ACCESS_ONCE(k->vfork_done);
66 if (likely(vfork))
67 return __to_kthread(vfork);
68 return NULL;
69}
57 70
58/** 71/**
59 * kthread_should_stop - should this kthread return now? 72 * kthread_should_stop - should this kthread return now?
@@ -313,15 +326,8 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data),
313 326
314static struct kthread *task_get_live_kthread(struct task_struct *k) 327static struct kthread *task_get_live_kthread(struct task_struct *k)
315{ 328{
316 struct kthread *kthread;
317
318 get_task_struct(k); 329 get_task_struct(k);
319 kthread = to_kthread(k); 330 return to_live_kthread(k);
320 /* It might have exited */
321 barrier();
322 if (k->vfork_done != NULL)
323 return kthread;
324 return NULL;
325} 331}
326 332
327static void __kthread_unpark(struct task_struct *k, struct kthread *kthread) 333static void __kthread_unpark(struct task_struct *k, struct kthread *kthread)