Messages in this thread | | | Date | Thu, 11 Apr 2013 17:29:43 +0530 | From | "Srivatsa S. Bhat" <> | Subject | Re: [PATCH] kthread: Prevent unpark race which puts threads on the wrong cpu |
| |
On 04/11/2013 05:13 PM, Srivatsa S. Bhat wrote: [...] > So Dave, could you kindly test the below patch on mainline? >
BTW, you don't need to try out any of the previous patches that I sent, just this one is good enough. Thanks!
Regards, Srivatsa S. Bhat
> > diff --git a/kernel/kthread.c b/kernel/kthread.c > index 691dc2e..9558355 100644 > --- a/kernel/kthread.c > +++ b/kernel/kthread.c > @@ -308,6 +308,15 @@ struct task_struct *kthread_create_on_cpu(int (*threadfn)(void *data), > to_kthread(p)->cpu = cpu; > /* Park the thread to get it out of TASK_UNINTERRUPTIBLE state */ > kthread_park(p); > + > + /* > + * Wait for p->on_rq to be reset to 0, to ensure that the per-cpu > + * migration thread (which belongs to the stop_task sched class) > + * doesn't run until the cpu is actually onlined and the thread is > + * unparked. > + */ > + if (!wait_task_inactive(p, TASK_INTERRUPTIBLE)) > + WARN_ON(1); > return p; > } >
| |