Commit abf1e853 authored by Andrew Morton's avatar Andrew Morton Committed by Len Brown

[PATCH] use wait_task_inactive() in kthread_bind()

From: Rusty Russell <rusty@rustcorp.com.au>

Make it clear that the reason we do wait_task_inactive is because
kthread_bind frobs with k->thread_info->cpu, which is only legal because
the task is definitely not running.

We can't use the normal migration thread code here, because it doesn't let
us bind to cpus which are offline yet, and also because we use this to
start the migration threads themselves.
parent d1dbcdee
...@@ -91,7 +91,6 @@ static void keventd_create_kthread(void *_create) ...@@ -91,7 +91,6 @@ static void keventd_create_kthread(void *_create)
} else { } else {
wait_for_completion(&create->started); wait_for_completion(&create->started);
create->result = find_task_by_pid(pid); create->result = find_task_by_pid(pid);
wait_task_inactive(create->result);
} }
complete(&create->done); complete(&create->done);
} }
...@@ -131,7 +130,9 @@ struct task_struct *kthread_create(int (*threadfn)(void *data), ...@@ -131,7 +130,9 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
void kthread_bind(struct task_struct *k, unsigned int cpu) void kthread_bind(struct task_struct *k, unsigned int cpu)
{ {
BUG_ON(k->state != TASK_INTERRUPTIBLE); BUG_ON(k->state != TASK_INTERRUPTIBLE);
k->thread_info->cpu = cpu; /* Must have done schedule() in kthread() before we set_task_cpu */
wait_task_inactive(k);
set_task_cpu(k, cpu);
k->cpus_allowed = cpumask_of_cpu(cpu); k->cpus_allowed = cpumask_of_cpu(cpu);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment