public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miao Xie <miaox@cn.fujitsu.com>
To: Paul Menage <menage@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH] cpusets: set task's cpu_allowed to cpu_possible_map when attaching it into top cpuset
Date: Tue, 23 Dec 2008 16:35:28 +0800	[thread overview]
Message-ID: <4950A2D0.80905@cn.fujitsu.com> (raw)

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>

---
 kernel/cpuset.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 96c0ba1..e087b72 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1332,10 +1332,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;
 
-- 1.5.4.rc3 


                 reply	other threads:[~2008-12-23  8:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4950A2D0.80905@cn.fujitsu.com \
    --to=miaox@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox