Skip to content

Commit

Permalink
cpusets: set task's cpu_allowed to cpu_possible_map when attaching it…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Miao Xie authored and Linus Torvalds committed Jan 8, 2009
1 parent 1333771 commit f5813d9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kernel/cpuset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1338,10 +1338,14 @@ static void cpuset_attach(struct cgroup_subsys *ss,
struct cpuset *oldcs = cgroup_cs(oldcont);
int err;

mutex_lock(&callback_mutex);
guarantee_online_cpus(cs, &cpus);
if (cs == &top_cpuset) {
cpus = cpu_possible_map;
} else {
mutex_lock(&callback_mutex);
guarantee_online_cpus(cs, &cpus);
mutex_unlock(&callback_mutex);
}
err = set_cpus_allowed_ptr(tsk, &cpus);
mutex_unlock(&callback_mutex);
if (err)
return;

Expand Down

0 comments on commit f5813d9

Please sign in to comment.