linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: a.p.zijlstra@chello.nl, mingo@kernel.org, pjt@google.com,
	paul@paulmenage.org, akpm@linux-foundation.org
Cc: rjw@sisk.pl, nacc@us.ibm.com, paulmck@linux.vnet.ibm.com,
	tglx@linutronix.de, seto.hidetoshi@jp.fujitsu.com, tj@kernel.org,
	mschmidt@redhat.com, berrange@redhat.com,
	nikunj@linux.vnet.ibm.com, vatsa@linux.vnet.ibm.com,
	liuj97@gmail.com, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, srivatsa.bhat@linux.vnet.ibm.com
Subject: [PATCH v3 3/5] cpusets: Update tasks' cpus_allowed mask upon updates to root cpuset
Date: Mon, 14 May 2012 04:46:23 +0530	[thread overview]
Message-ID: <20120513231609.3566.23600.stgit@srivatsabhat> (raw)
In-Reply-To: <20120513231325.3566.37740.stgit@srivatsabhat>

The root cpuset's cpus_allowed mask can get updated during CPU hotplug.
However, during those updates, the tasks belonging to the root cpuset
aren't touched at all - their cpus_allowed masks aren't updated to reflect
the change in the configuration of the cpuset they belong to.

Fix this by moving the update of top_cpuset.cpus_allowed to
scan_cpusets_upon_hotplug() and ensure that the call to update_tasks_cpumask()
is not missed out for the root cpuset, including for cpu online events.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org
---

 kernel/cpuset.c |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 87b0048..0fb9bff 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -150,6 +150,7 @@ typedef enum {
 /* the type of hotplug event */
 enum hotplug_event {
 	CPUSET_CPU_OFFLINE,
+	CPUSET_CPU_ONLINE,
 	CPUSET_MEM_OFFLINE,
 };
 
@@ -2058,10 +2059,14 @@ scan_cpusets_upon_hotplug(struct cpuset *root, enum hotplug_event event)
 			if (cpumask_subset(cp->cpus_allowed, cpu_active_mask))
 				continue;
 
-			/* Remove offline cpus from this cpuset. */
 			mutex_lock(&callback_mutex);
-			cpumask_and(cp->cpus_allowed, cp->cpus_allowed,
-							cpu_active_mask);
+			/* top_cpuset.cpus_allowed must track cpu_active_mask */
+			if (cp == &top_cpuset)
+				cpumask_copy(cp->cpus_allowed, cpu_active_mask);
+			else
+				/* Remove offline cpus from this cpuset. */
+				cpumask_and(cp->cpus_allowed, cp->cpus_allowed,
+							      cpu_active_mask);
 			mutex_unlock(&callback_mutex);
 
 			/* Move tasks from the empty cpuset to a parent */
@@ -2072,6 +2077,20 @@ scan_cpusets_upon_hotplug(struct cpuset *root, enum hotplug_event event)
 		}
 		break;
 
+	case CPUSET_CPU_ONLINE:
+		/*
+		 * Restore only the top_cpuset because it has to track
+		 * cpu_active_mask always.
+		 */
+		if (root == &top_cpuset) {
+			mutex_lock(&callback_mutex);
+			cpumask_copy(root->cpus_allowed, cpu_active_mask);
+			mutex_unlock(&callback_mutex);
+			update_tasks_cpumask(root, NULL);
+		}
+		list_del(queue.next);
+		break;
+
 	case CPUSET_MEM_OFFLINE:
 		while (!list_empty(&queue)) {
 			cp = traverse_cpusets(&queue);
@@ -2105,7 +2124,8 @@ scan_cpusets_upon_hotplug(struct cpuset *root, enum hotplug_event event)
  * but making no active use of cpusets.
  *
  * This routine ensures that top_cpuset.cpus_allowed tracks
- * cpu_active_mask on each CPU hotplug (cpuhp) event.
+ * cpu_active_mask on each CPU hotplug (cpuhp) event. (This maintenance
+ * is actually implemented in scan_cpusets_upon_hotplug().)
  *
  * Called within get_online_cpus().  Needs to call cgroup_lock()
  * before calling generate_sched_domains().
@@ -2120,11 +2140,10 @@ void cpuset_update_active_cpus(bool cpu_online)
 	int ndoms;
 
 	cgroup_lock();
-	mutex_lock(&callback_mutex);
-	cpumask_copy(top_cpuset.cpus_allowed, cpu_active_mask);
-	mutex_unlock(&callback_mutex);
 
-	if (!cpu_online)
+	if (cpu_online)
+		scan_cpusets_upon_hotplug(&top_cpuset, CPUSET_CPU_ONLINE);
+	else
 		scan_cpusets_upon_hotplug(&top_cpuset, CPUSET_CPU_OFFLINE);
 
 	ndoms = generate_sched_domains(&doms, &attr);


  parent reply	other threads:[~2012-05-13 23:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-13 23:14 [PATCH v3 0/5] CPU hotplug, cpusets: Fix issues with cpusets handling during suspend/resume Srivatsa S. Bhat
2012-05-13 23:15 ` [PATCH v3 1/5] cpusets, hotplug: Implement cpuset tree traversal in a helper function Srivatsa S. Bhat
2012-05-15  0:03   ` David Rientjes
2012-05-15 12:15     ` Srivatsa S. Bhat
2012-05-15 18:04       ` David Rientjes
2012-05-13 23:15 ` [PATCH v3 2/5] cpusets, hotplug: Restructure functions that are invoked during hotplug Srivatsa S. Bhat
2012-05-15  0:27   ` David Rientjes
2012-05-15 12:25     ` Srivatsa S. Bhat
2012-05-13 23:16 ` Srivatsa S. Bhat [this message]
2012-05-15  0:31   ` [PATCH v3 3/5] cpusets: Update tasks' cpus_allowed mask upon updates to root cpuset David Rientjes
2012-05-13 23:16 ` [PATCH v3 4/5] cpusets: Add provisions for distinguishing CPU Hotplug in suspend/resume path Srivatsa S. Bhat
2012-05-15  0:33   ` David Rientjes
2012-05-15 12:29     ` Srivatsa S. Bhat
2012-05-15 18:34       ` David Rientjes
2012-05-15 19:17         ` Srivatsa S. Bhat
2012-05-15 20:39           ` David Rientjes
2012-05-13 23:17 ` [PATCH v3 5/5] cpusets, suspend: Save and restore cpusets during suspend/resume Srivatsa S. Bhat
2012-05-15  0:37   ` David Rientjes
2012-05-15  1:40     ` Nishanth Aravamudan
2012-05-15  4:04       ` David Rientjes
2012-05-15  4:45         ` Nishanth Aravamudan
2012-05-15 18:31           ` David Rientjes
2012-05-15 20:10             ` Peter Zijlstra
2012-05-15 21:05               ` David Rientjes
2012-05-15 21:08                 ` Peter Zijlstra
2012-05-15 21:21                   ` Srivatsa S. Bhat
2012-05-15 21:24                     ` Peter Zijlstra
2012-05-15 21:24                   ` David Rientjes
2012-05-15 21:42                     ` Srivatsa S. Bhat
2012-05-15 21:49                       ` David Rientjes
2012-05-15 22:16                         ` Srivatsa S. Bhat
2012-05-15 22:32                           ` David Rientjes
2012-05-16  8:20                             ` Srivatsa S. Bhat
2012-05-16  8:42                               ` Srivatsa S. Bhat
2012-05-16 21:24                           ` Peter Zijlstra
2012-05-17  9:57                             ` Srivatsa S. Bhat
2012-05-15 21:13                 ` Peter Zijlstra
2012-05-15 21:37                   ` David Rientjes
2012-05-15  9:24       ` Srivatsa S. Bhat
2012-05-14 23:58 ` [PATCH v3 0/5] CPU hotplug, cpusets: Fix issues with cpusets handling " David Rientjes
2012-05-15 12:10   ` Srivatsa S. Bhat

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=20120513231609.3566.23600.stgit@srivatsabhat \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=berrange@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=liuj97@gmail.com \
    --cc=mingo@kernel.org \
    --cc=mschmidt@redhat.com \
    --cc=nacc@us.ibm.com \
    --cc=nikunj@linux.vnet.ibm.com \
    --cc=paul@paulmenage.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=pjt@google.com \
    --cc=rjw@sisk.pl \
    --cc=seto.hidetoshi@jp.fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=vatsa@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).