From: Oleg Nesterov Now that wait_task_inactive(task, state) checks task->state == state, we can simplify the code and make this debugging check more robust. Signed-off-by: Oleg Nesterov Cc: Roland McGrath Cc: Ingo Molnar Signed-off-by: Andrew Morton --- kernel/kthread.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff -puN kernel/kthread.c~kthread_bind-use-wait_task_inactivetask_uninterruptible kernel/kthread.c --- a/kernel/kthread.c~kthread_bind-use-wait_task_inactivetask_uninterruptible +++ a/kernel/kthread.c @@ -172,12 +172,11 @@ EXPORT_SYMBOL(kthread_create); */ void kthread_bind(struct task_struct *k, unsigned int cpu) { - if (k->state != TASK_UNINTERRUPTIBLE) { + /* Must have done schedule() in kthread() before we set_task_cpu */ + if (!wait_task_inactive(k, TASK_UNINTERRUPTIBLE)) { WARN_ON(1); return; } - /* Must have done schedule() in kthread() before we set_task_cpu */ - wait_task_inactive(k, 0); set_task_cpu(k, cpu); k->cpus_allowed = cpumask_of_cpu(cpu); k->rt.nr_cpus_allowed = 1; _