From: Xunlei Pang <xlpang@126.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Xunlei Pang <pang.xunlei@linaro.org>
Subject: [PATCH] sched: Avoid sched domain rebuilding when hotplugging an isolate cpu
Date: Fri, 17 Jul 2015 16:03:45 +0800 [thread overview]
Message-ID: <1437120225-16466-1-git-send-email-xlpang@126.com> (raw)
From: Xunlei Pang <pang.xunlei@linaro.org>
The sched domain is always rebuilt when hotplugging an isolate cpu,
as we can see in partition_sched_domains() with the NULL doms_new,
current sched domain is destroyed, then rebuilt. Worse still, the
rebuilding will reset all the parameters of the sched_domain. This
makes no sense and contradicts the isloate concept.
The patch avoids the rebuilding if the hotplug cpu is an isolate one.
Signed-off-by: Xunlei Pang <pang.xunlei@linaro.org>
---
kernel/sched/core.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bb8f3ad..bae817e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6862,9 +6862,12 @@ error:
}
static cpumask_var_t *doms_cur; /* current sched domains */
-static int ndoms_cur; /* number of sched domains in 'doms_cur' */
+/* effective number of sched domains in 'doms_cur' */
+static int ndoms_cur;
+/* original number of sched domains in 'doms_cur' */
+static int ndoms_orig;
+/* attribues of custom domains in 'doms_cur' */
static struct sched_domain_attr *dattr_cur;
- /* attribues of custom domains in 'doms_cur' */
/*
* Special case: If a kmalloc of a doms_cur partition (array of
@@ -6918,6 +6921,7 @@ static int init_sched_domains(const struct cpumask *cpu_map)
int err;
arch_update_cpu_topology();
+ ndoms_orig = 1;
ndoms_cur = 1;
doms_cur = alloc_sched_domains(ndoms_cur);
if (!doms_cur)
@@ -6990,6 +6994,7 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
{
int i, j, n;
int new_topology;
+ bool borrow_needed = false;
mutex_lock(&sched_domains_mutex);
@@ -6999,6 +7004,13 @@ void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[],
/* Let architecture update cpu core mappings. */
new_topology = arch_update_cpu_topology();
+ if (doms_new == NULL && doms_cur != &fallback_doms) {
+ doms_new = &fallback_doms;
+ cpumask_andnot(doms_new[0], cpu_active_mask, cpu_isolated_map);
+ borrow_needed = true;
+ WARN_ON_ONCE(dattr_new);
+ }
+
n = doms_new ? ndoms_new : 0;
/* Destroy deleted domains */
@@ -7036,10 +7048,22 @@ match2:
}
/* Remember the new sched domains */
- if (doms_cur != &fallback_doms)
- free_sched_domains(doms_cur, ndoms_cur);
+ if (doms_cur != &fallback_doms && !borrow_needed)
+ free_sched_domains(doms_cur, ndoms_orig);
kfree(dattr_cur); /* kfree(NULL) is safe */
- doms_cur = doms_new;
+
+ if (borrow_needed) {
+ /*
+ * Borrow previous doms_cur as new storage, so that
+ * fallback_doms can be used as the temporal storage
+ * in the future rebuilding.
+ */
+ cpumask_copy(doms_cur[0], doms_new[0]);
+ } else {
+ doms_cur = doms_new;
+ ndoms_orig = ndoms_new;
+ }
+
dattr_cur = dattr_new;
ndoms_cur = ndoms_new;
--
1.9.1
next reply other threads:[~2015-07-17 8:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 8:03 Xunlei Pang [this message]
2015-07-30 10:30 ` Peter Zijlstra
2015-07-30 10:54 ` pang.xunlei
2015-07-30 11:51 ` Peter Zijlstra
2015-07-30 12:05 ` pang.xunlei
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=1437120225-16466-1-git-send-email-xlpang@126.com \
--to=xlpang@126.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pang.xunlei@linaro.org \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®