Not-Yet-Signed-off-by: Frederic Weisbecker <fweis...@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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/