aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2009-04-02 19:57:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-02 22:04:56 -0400
commit0b4217b3fdddc4a58939720d3ed809537577d48b (patch)
tree9bda180eb4e9fed454453b4aeaf9447602c74022
parent83aae4c737866da3280f51fd15da58eddd788397 (diff)
cpuset: fix possible races in cpu/memory hotplug
Change to cpuset->cpus_allowed and cpuset->mems_allowed should be protected by callback_mutex, otherwise the reader may read wrong cpus/mems. This is cpuset's lock rule. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Paul Menage <menage@google.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/cpuset.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index ee5ec386aa8b..31737957cb62 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2070,7 +2070,9 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb,
2070 } 2070 }
2071 2071
2072 cgroup_lock(); 2072 cgroup_lock();
2073 mutex_lock(&callback_mutex);
2073 cpumask_copy(top_cpuset.cpus_allowed, cpu_online_mask); 2074 cpumask_copy(top_cpuset.cpus_allowed, cpu_online_mask);
2075 mutex_unlock(&callback_mutex);
2074 scan_for_empty_cpusets(&top_cpuset); 2076 scan_for_empty_cpusets(&top_cpuset);
2075 ndoms = generate_sched_domains(&doms, &attr); 2077 ndoms = generate_sched_domains(&doms, &attr);
2076 cgroup_unlock(); 2078 cgroup_unlock();
@@ -2093,11 +2095,12 @@ static int cpuset_track_online_nodes(struct notifier_block *self,
2093 cgroup_lock(); 2095 cgroup_lock();
2094 switch (action) { 2096 switch (action) {
2095 case MEM_ONLINE: 2097 case MEM_ONLINE:
2096 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2097 break;
2098 case MEM_OFFLINE: 2098 case MEM_OFFLINE:
2099 mutex_lock(&callback_mutex);
2099 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; 2100 top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
2100 scan_for_empty_cpusets(&top_cpuset); 2101 mutex_unlock(&callback_mutex);
2102 if (action == MEM_OFFLINE)
2103 scan_for_empty_cpusets(&top_cpuset);
2101 break; 2104 break;
2102 default: 2105 default:
2103 break; 2106 break;