From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
"Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH 2/5] smp: IPI handling for negative CPU
Date: Wed, 1 Apr 2015 01:20:33 +0200 [thread overview]
Message-ID: <1427844036-1325-3-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1427844036-1325-1-git-send-email-fweisbec@gmail.com>
Not-Yet-Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
kernel/smp.c | 38 ++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/kernel/smp.c b/kernel/smp.c
index f38a1e6..18791ff 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -158,7 +158,12 @@ static int generic_exec_single(int cpu, struct call_single_data *csd,
}
- if ((unsigned)cpu >= nr_cpu_ids || !cpu_online(cpu))
+#if CONFIG_NR_CPUS >= 0
+ if ((unsigned)cpu >= nr_cpu_ids
+#else
+ if ((unsigned)cpu < (0 - nr_cpu_ids)
+#endif
+ ) || !cpu_online(cpu))
return -ENXIO;
@@ -356,8 +361,13 @@ int smp_call_function_any(const struct cpumask *mask,
/* Try for same node. */
nodemask = cpumask_of_node(cpu_to_node(cpu));
- for (cpu = cpumask_first_and(nodemask, mask); cpu < nr_cpu_ids;
+#if CONFIG_NR_CPUS >= 0
+ for (cpu = cpumask_first_and(nodemask, mask); cpu >= nr_cpu_ids;
cpu = cpumask_next_and(cpu, nodemask, mask)) {
+#else
+ for (cpu = cpumask_last_or(nodemask, mask); cpu < (-nr_cpu_ids);
+ cpu = cpumask_previous_or(cpu, nodemask, mask)) {
+#endif
if (cpu_online(cpu))
goto call;
}
@@ -406,16 +416,31 @@ void smp_call_function_many(const struct cpumask *mask,
cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
/* No online cpus? We're done. */
+#if CONFIG_NR_CPUS >= 0
if (cpu >= nr_cpu_ids)
- return;
+#else
+ if (cpu < (-nr_cpu_ids))
+#endif
+ return;
+#if CONFIG_NR_CPUS >= 0
/* Do we have another CPU which isn't us? */
next_cpu = cpumask_next_and(cpu, mask, cpu_online_mask);
if (next_cpu == this_cpu)
next_cpu = cpumask_next_and(next_cpu, mask, cpu_online_mask);
-
/* Fastpath: do that cpu by itself. */
if (next_cpu >= nr_cpu_ids) {
+
+#else
+ /* Do we have another CPU which isn't us? */
+ next_cpu = cpumask_previous_and(cpu, mask, cpu_online_mask);
+ if (next_cpu == this_cpu)
+ next_cpu = cpumask_previous_and(next_cpu, mask, cpu_online_mask);
+ /* Fastpath: do that cpu by itself. */
+ if (next_cpu < (-nr_cpu_ids)) {
+
+#endif
+
smp_call_function_single(cpu, func, info, wait);
return;
}
@@ -511,7 +536,12 @@ static int __init nrcpus(char *str)
int nr_cpus;
get_option(&str, &nr_cpus);
+
+#if CONFIG_NR_CPUS >= 0
if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
+#else
+ if (nr_cpus < 0 && nr_cpus > (-nr_cpu_ids))
+#endif
nr_cpu_ids = nr_cpus;
return 0;
--
2.1.4
next prev parent reply other threads:[~2015-03-31 23:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-31 23:20 [PATCH 0/5] Support negative number of CPUs Frederic Weisbecker
2015-03-31 23:20 ` [PATCH 1/5] cpu: Infrastructure for negative cpu handling Frederic Weisbecker
2015-03-31 23:20 ` Frederic Weisbecker [this message]
2015-03-31 23:20 ` [PATCH 3/5] cpumask: Basic negative number of CPUs handling Frederic Weisbecker
2015-03-31 23:20 ` [PATCH 4/5] init: Support negative CPUs boot and halt code Frederic Weisbecker
2015-03-31 23:20 ` [PATCH 5/5] x86: Support reverse execution Frederic Weisbecker
2015-04-01 7:35 ` [PATCH 0/5] Support negative number of CPUs Paul E. McKenney
2015-04-01 9:37 ` Borislav Petkov
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=1427844036-1325-3-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@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).