mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot for Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	torvalds@linux-foundation.org, a.p.zijlstra@chello.nl,
	srivatsa.bhat@linux.vnet.ibm.com, akpm@linux-foundation.org,
	tglx@linutronix.de
Subject: [tip:sched/core] cpusets, hotplug: Implement cpuset tree traversal in a helper function
Date: Tue, 24 Jul 2012 07:15:41 -0700	[thread overview]
Message-ID: <tip-80d1fa6463d934969b7aebf04107fc133463f0f6@git.kernel.org> (raw)
In-Reply-To: <20120524141635.3692.893.stgit@srivatsabhat.in.ibm.com>

Commit-ID:  80d1fa6463d934969b7aebf04107fc133463f0f6
Gitweb:     http://git.kernel.org/tip/80d1fa6463d934969b7aebf04107fc133463f0f6
Author:     Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
AuthorDate: Thu, 24 May 2012 19:46:41 +0530
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 24 Jul 2012 13:53:18 +0200

cpusets, hotplug: Implement cpuset tree traversal in a helper function

At present, the functions that deal with cpusets during CPU/Mem hotplug
are quite messy, since a lot of the functionality is mixed up without clear
separation. And this takes a toll on optimization as well. For example,
the function cpuset_update_active_cpus() is called on both CPU offline and CPU
online events; and it invokes scan_for_empty_cpusets(), which makes sense
only for CPU offline events. And hence, the current code ends up unnecessarily
traversing the cpuset tree during CPU online also.

As a first step towards cleaning up those functions, encapsulate the cpuset
tree traversal in a helper function, so as to facilitate upcoming changes.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20120524141635.3692.893.stgit@srivatsabhat.in.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/cpuset.c |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 746d1ee..ba96349 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1990,6 +1990,32 @@ static void remove_tasks_in_empty_cpuset(struct cpuset *cs)
 }
 
 /*
+ * Helper function to traverse cpusets.
+ * It can be used to walk the cpuset tree from top to bottom, completing
+ * one layer before dropping down to the next (thus always processing a
+ * node before any of its children).
+ */
+static struct cpuset *cpuset_next(struct list_head *queue)
+{
+	struct cpuset *cp;
+	struct cpuset *child;	/* scans child cpusets of cp */
+	struct cgroup *cont;
+
+	if (list_empty(queue))
+		return NULL;
+
+	cp = list_first_entry(queue, struct cpuset, stack_list);
+	list_del(queue->next);
+	list_for_each_entry(cont, &cp->css.cgroup->children, sibling) {
+		child = cgroup_cs(cont);
+		list_add_tail(&child->stack_list, queue);
+	}
+
+	return cp;
+}
+
+
+/*
  * Walk the specified cpuset subtree and look for empty cpusets.
  * The tasks of such cpuset must be moved to a parent cpuset.
  *
@@ -2008,19 +2034,11 @@ static void scan_for_empty_cpusets(struct cpuset *root)
 {
 	LIST_HEAD(queue);
 	struct cpuset *cp;	/* scans cpusets being updated */
-	struct cpuset *child;	/* scans child cpusets of cp */
-	struct cgroup *cont;
 	static nodemask_t oldmems;	/* protected by cgroup_mutex */
 
 	list_add_tail((struct list_head *)&root->stack_list, &queue);
 
-	while (!list_empty(&queue)) {
-		cp = list_first_entry(&queue, struct cpuset, stack_list);
-		list_del(queue.next);
-		list_for_each_entry(cont, &cp->css.cgroup->children, sibling) {
-			child = cgroup_cs(cont);
-			list_add_tail(&child->stack_list, &queue);
-		}
+	while ((cp = cpuset_next(&queue)) != NULL) {
 
 		/* Continue past cpusets with all cpus, mems online */
 		if (cpumask_subset(cp->cpus_allowed, cpu_active_mask) &&

  parent reply	other threads:[~2012-07-24 14:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-24 14:16 [PATCH v6 0/4] CPU hotplug, cpusets, suspend/resume: Fixes, cleanups and optimizations Srivatsa S. Bhat
2012-05-24 14:16 ` [PATCH v6 1/4] CPU hotplug, cpusets, suspend: Don't modify cpusets during suspend/resume Srivatsa S. Bhat
2012-06-20 10:44   ` [tip:sched/core] CPU hotplug, cpusets, suspend: Don' t " tip-bot for Srivatsa S. Bhat
2012-07-24 14:14   ` tip-bot for Srivatsa S. Bhat
2012-05-24 14:16 ` [PATCH v6 2/4] cpusets, hotplug: Implement cpuset tree traversal in a helper function Srivatsa S. Bhat
2012-06-20 10:45   ` [tip:sched/core] " tip-bot for Srivatsa S. Bhat
2012-07-24 14:15   ` tip-bot for Srivatsa S. Bhat [this message]
2012-05-24 14:16 ` [PATCH v6 3/4] cpusets, hotplug: Restructure functions that are invoked during hotplug Srivatsa S. Bhat
2012-06-20 10:46   ` [tip:sched/core] " tip-bot for Srivatsa S. Bhat
2012-07-24 14:16   ` tip-bot for Srivatsa S. Bhat
2012-05-24 14:17 ` [PATCH v6 4/4] cpusets: Remove/update outdated comments Srivatsa S. Bhat
2012-06-20 10:47   ` [tip:sched/core] " tip-bot for Srivatsa S. Bhat
2012-07-24 14:17   ` tip-bot for Srivatsa S. Bhat
2012-05-25  9:38 ` [PATCH v6 0/4] CPU hotplug, cpusets, suspend/resume: Fixes, cleanups and optimizations Peter Zijlstra
2012-05-25 11:22   ` Srivatsa S. Bhat
2012-06-20  9:36 ` Srivatsa S. Bhat
2012-06-20 11:39   ` Ingo Molnar
2012-06-20 14:17     ` Srivatsa S. Bhat
2012-06-20 14:26       ` Srivatsa S. Bhat
2012-06-20 14:47       ` Ingo Molnar
2012-06-20 16:06         ` 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=tip-80d1fa6463d934969b7aebf04107fc133463f0f6@git.kernel.org \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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

Powered by JetHome