From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753196AbbCaXV3 (ORCPT ); Tue, 31 Mar 2015 19:21:29 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35381 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752756AbbCaXUr (ORCPT ); Tue, 31 Mar 2015 19:20:47 -0400 From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , "Paul E . McKenney" Subject: [PATCH 2/5] smp: IPI handling for negative CPU Date: Wed, 1 Apr 2015 01:20:33 +0200 Message-Id: <1427844036-1325-3-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427844036-1325-1-git-send-email-fweisbec@gmail.com> References: <1427844036-1325-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Not-Yet-Signed-off-by: Frederic Weisbecker --- 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