sched: Fix balance vs hotplug race
commita09adfeb9ea89d22c301749a87480ac98edc2cce
authorPeter Zijlstra <a.p.zijlstra@chello.nl>
Wed, 25 Nov 2009 12:31:39 +0000 (25 13:31 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 6 Jan 2010 23:04:49 +0000 (6 15:04 -0800)
tree3416e3c66f940ed08bf18f41e4cb3212fb8638cd
parentfb70ac4b23fc108eb92eef9434e111bbdd7fd922
sched: Fix balance vs hotplug race

commit 6ad4c18884e864cf4c77f9074d3d1816063f99cd upstream.

Since (e761b77: cpu hotplug, sched: Introduce cpu_active_map and redo
sched domain managment) we have cpu_active_mask which is suppose to rule
scheduler migration and load-balancing, except it never (fully) did.

The particular problem being solved here is a crash in try_to_wake_up()
where select_task_rq() ends up selecting an offline cpu because
select_task_rq_fair() trusts the sched_domain tree to reflect the
current state of affairs, similarly select_task_rq_rt() trusts the
root_domain.

However, the sched_domains are updated from CPU_DEAD, which is after the
cpu is taken offline and after stop_machine is done. Therefore it can
race perfectly well with code assuming the domains are right.

Cure this by building the domains from cpu_active_mask on
CPU_DOWN_PREPARE.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Holger Hoffstätte <holger.hoffstaette@googlemail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/cpumask.h
kernel/cpu.c
kernel/cpuset.c
kernel/sched.c