The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] cpuset: fix possible races in cpu/memory hotplug
@ 2009-02-03  9:26 Li Zefan
  0 siblings, 0 replies; only message in thread
From: Li Zefan @ 2009-02-03  9:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Paul Menage, LKML

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>
---
 kernel/cpuset.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index a856788..39f7d94 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -2061,7 +2061,9 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb,
 	}
 
 	cgroup_lock();
+	mutex_lock(&callback_mutex);
 	cpumask_copy(top_cpuset.cpus_allowed, cpu_online_mask);
+	mutex_unlock(&callback_mutex);
 	scan_for_empty_cpusets(&top_cpuset);
 	ndoms = generate_sched_domains(&doms, &attr);
 	cgroup_unlock();
@@ -2084,11 +2086,12 @@ static int cpuset_track_online_nodes(struct notifier_block *self,
 	cgroup_lock();
 	switch (action) {
 	case MEM_ONLINE:
-		top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
-		break;
 	case MEM_OFFLINE:
+		mutex_lock(&callback_mutex);
 		top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY];
-		scan_for_empty_cpusets(&top_cpuset);
+		mutex_unlock(&callback_mutex);
+		if (action == MEM_OFFLINE)
+			scan_for_empty_cpusets(&top_cpuset);
 		break;
 	default:
 		break;
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-03  9:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-03  9:26 [PATCH] cpuset: fix possible races in cpu/memory hotplug Li Zefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox