Skip to content

Commit 293adee

Browse files
Oleg Nesterovtorvalds
authored andcommitted
kthread_bind: use wait_task_inactive(TASK_UNINTERRUPTIBLE)
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 <oleg@tv-sign.ru> Cc: Roland McGrath <roland@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 656eb2c commit 293adee

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎kernel/kthread.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,11 @@ EXPORT_SYMBOL(kthread_create);
171171
*/
172172
void kthread_bind(struct task_struct *k, unsigned int cpu)
173173
{
174-
if (k->state != TASK_UNINTERRUPTIBLE) {
174+
/* Must have done schedule() in kthread() before we set_task_cpu */
175+
if (!wait_task_inactive(k, TASK_UNINTERRUPTIBLE)) {
175176
WARN_ON(1);
176177
return;
177178
}
178-
/* Must have done schedule() in kthread() before we set_task_cpu */
179-
wait_task_inactive(k, 0);
180179
set_task_cpu(k, cpu);
181180
k->cpus_allowed = cpumask_of_cpu(cpu);
182181
k->rt.nr_cpus_allowed = 1;

0 commit comments

Comments
 (0)