sched: Fix broken assertion
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Thu, 17 Dec 2009 12:16:31 +0000 (13:16 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Sep 2010 20:18:01 +0000 (13:18 -0700)
commit 077614ee1e93245a3b9a4e1213659405dbeb0ba6 upstream

There's a preemption race in the set_task_cpu() debug check in
that when we get preempted after setting task->state we'd still
be on the rq proper, but fail the test.

Check for preempted tasks, since those are always on the RQ.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20091217121830.137155561@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/sched.c

index 94b1ca17db3882e98dc2558fa58a765b381b9869..947b26df11df624c24c13bced826948983222eb1 100644 (file)
@@ -2071,7 +2071,8 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
         * We should never call set_task_cpu() on a blocked task,
         * ttwu() will sort out the placement.
         */
-       WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING);
+       WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING &&
+                       !(task_thread_info(p)->preempt_count & PREEMPT_ACTIVE));
 #endif
 
        trace_sched_migrate_task(p, new_cpu);