lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  1 Apr 2015 01:20:33 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	Frederic Weisbecker <fweisbec@...il.com>,
	"Paul E . McKenney" <paulmck@...ux.vnet.ibm.com>
Subject: [PATCH 2/5] smp: IPI handling for negative CPU

Not-Yet-Signed-off-by: Frederic Weisbecker <fweisbec@...il.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

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ