[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120504192014.4603.41932.stgit@srivatsabhat>
Date: Sat, 05 May 2012 00:50:25 +0530
From: "Srivatsa S. Bhat" <srivatsa.bhat@...ux.vnet.ibm.com>
To: a.p.zijlstra@...llo.nl, mingo@...nel.org, pjt@...gle.com,
paul@...lmenage.org, akpm@...ux-foundation.org
Cc: rjw@...k.pl, nacc@...ibm.com, paulmck@...ux.vnet.ibm.com,
tglx@...utronix.de, seto.hidetoshi@...fujitsu.com, rob@...dley.net,
tj@...nel.org, mschmidt@...hat.com, berrange@...hat.com,
nikunj@...ux.vnet.ibm.com, vatsa@...ux.vnet.ibm.com,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
linux-pm@...r.kernel.org, srivatsa.bhat@...ux.vnet.ibm.com
Subject: [PATCH v2 6/7] cpusets: Optimize the implementation of
guarantee_online_cpus()
A cpuset's cpus_allowed mask is kept updated upon CPU hotplug
events in such a way that it always contains online cpus. Using
this observation, rework the body of guarantee_online_cpus().
Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@...ux.vnet.ibm.com>
---
kernel/cpuset.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index c501a90..6446095 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -301,20 +301,23 @@ static struct file_system_type cpuset_fs_type = {
* One way or another, we guarantee to return some non-empty subset
* of cpu_online_mask.
*
+ * Optimization: The cpus_allowed mask of a cpuset is maintained in such
+ * a way as to always have online cpus, by doing the cpuset hiearchy walk
+ * if/when necessary during CPU hotplug. And hence, it fits the above
+ * requirement perfectly. The only point to watch out is that cpus_allowed
+ * can be empty when the cpuset has no tasks and user_cpus_allowed is empty.
+ *
* Call with callback_mutex held.
*/
static void guarantee_online_cpus(const struct cpuset *cs,
struct cpumask *pmask)
{
- while (cs && !cpumask_intersects(cs->user_cpus_allowed,
- cpu_online_mask))
- cs = cs->parent;
-
- if (cs)
- cpumask_and(pmask, cs->user_cpus_allowed, cpu_online_mask);
+ if (cs && !cpumask_empty(cs->cpus_allowed))
+ cpumask_copy(pmask, cs->cpus_allowed);
else
cpumask_copy(pmask, cpu_online_mask);
+
BUG_ON(!cpumask_intersects(pmask, cpu_online_mask));
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists