Skip to content

Commit

Permalink
kthread_bind: use wait_task_inactive(TASK_UNINTERRUPTIBLE)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Roland McGrath <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Oleg Nesterov authored and torvalds committed Oct 20, 2008
1 parent 656eb2c commit 293adee
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kernel/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,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;
Expand Down

0 comments on commit 293adee

Please sign in to comment.