sched: Ensure set_task_cpu() is never called on blocked tasks
commit854c98401284a312d28f3115954ce8965f437df1
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Wed, 16 Dec 2009 17:04:36 +0000 (16 18:04 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 20 Sep 2010 20:18:00 +0000 (20 13:18 -0700)
treef7dfbcf2f68904d29cedd890686db6e940e182f6
parent9afee77b0c1a234006146b1d09a87c1c0216201d
sched: Ensure set_task_cpu() is never called on blocked tasks

commit e2912009fb7b715728311b0d8fe327a1432b3f79 upstream

In order to clean up the set_task_cpu() rq dependencies we need
to ensure it is never called on blocked tasks because such usage
does not pair with consistent rq->lock usage.

This puts the migration burden on ttwu().

Furthermore we need to close a race against changing
->cpus_allowed, since select_task_rq() runs with only preemption
disabled.

For sched_fork() this is safe because the child isn't in the
tasklist yet, for wakeup we fix this by synchronizing
set_cpus_allowed_ptr() against TASK_WAKING, which leaves
sched_exec to be a problem

This also closes a hole in (6ad4c1888 sched: Fix balance vs
hotplug race) where ->select_task_rq() doesn't validate the
result against the sched_domain/root_domain.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <20091216170517.807938893@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