aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2009-01-07 21:08:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-08 11:31:11 -0500
commitf5813d94279a18ff5936d675e24b44b44a571197 (patch)
tree0c565bd5535f0f5623984e65403bda9c41b3a148
parent13337714f3b0307dc7f75ef5d83ecf0db2abbd65 (diff)
cpusets: set task's cpu_allowed to cpu_possible_map when attaching it into top cpuset
I found a bug on my dual-cpu box. I created a sub cpuset in top cpuset and assign 1 to its cpus. And then we attach some tasks into this sub cpuset. After this, we offline CPU1. Now, the tasks in this new cpuset are moved into top cpuset automatically because there is no cpu in sub cpuset. Then we online CPU1, we find all the tasks which doesn't belong to top cpuset originally just run on CPU0. We fix this bug by setting task's cpu_allowed to cpu_possible_map when attaching it into top cpuset. This method needn't modify the current behavior of cpusets on CPU hotplug, and all of tasks in top cpuset use cpu_possible_map to initialize their cpu_allowed. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Cc: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/cpuset.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index a841b5c01ef9..6012e326e856 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1338,10 +1338,14 @@ static void cpuset_attach(struct cgroup_subsys *ss,
1338 struct cpuset *oldcs = cgroup_cs(oldcont); 1338 struct cpuset *oldcs = cgroup_cs(oldcont);
1339 int err; 1339 int err;
1340 1340
1341 mutex_lock(&callback_mutex); 1341 if (cs == &top_cpuset) {
1342 guarantee_online_cpus(cs, &cpus); 1342 cpus = cpu_possible_map;
1343 } else {
1344 mutex_lock(&callback_mutex);
1345 guarantee_online_cpus(cs, &cpus);
1346 mutex_unlock(&callback_mutex);
1347 }
1343 err = set_cpus_allowed_ptr(tsk, &cpus); 1348 err = set_cpus_allowed_ptr(tsk, &cpus);
1344 mutex_unlock(&callback_mutex);
1345 if (err) 1349 if (err)
1346 return; 1350 return;
1347 1351