sched: Ensure set_task_cpu() is never called on blocked tasks
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Wed, 16 Dec 2009 17:04:36 +0000 (18:04 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 16 Dec 2009 18:01:56 +0000 (19:01 +0100)
commite2912009fb7b715728311b0d8fe327a1432b3f79
tree9918e2f9690d85b7d7f5550d09f0ae6cc3fa4e0f
parent06b83b5fbea273672822b6ee93e16781046553ec
sched: Ensure set_task_cpu() is never called on blocked tasks

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>
kernel/sched.c