[PATCH] PowerPC: Fix num_cpus calculation in smp_call_function_map()



[POWERPC]: Fix num_cpus calculation in smp_call_function_map().

In smp_call_function_map(), num_cpus is set to the number of online CPUs minus
one. However, if the CPU mask does not include all CPUs (except the one we're
running on), the routine will hang in the first while() loop until the 8 second
timeout occurs.

The num_cpus should be set to the number of CPUs specified in the mask passed
into the routine, after we've made any modifications to the mask. With this
change, we can also get rid of the call to cpus_empty() and avoid adding
another pass through the bitmask.

Signed-off-by: Kevin Corry <kevcorry@xxxxxxxxxx>
Signed-off-by: Carl Love <carll@xxxxxxxxxx>

Index: linux-2.6.23-rc1/arch/powerpc/kernel/smp.c
===================================================================
--- linux-2.6.23-rc1.orig/arch/powerpc/kernel/smp.c
+++ linux-2.6.23-rc1/arch/powerpc/kernel/smp.c
@@ -212,11 +212,6 @@ int smp_call_function_map(void (*func) (
atomic_set(&data.finished, 0);

spin_lock(&call_lock);
- /* Must grab online cpu count with preempt disabled, otherwise
- * it can change. */
- num_cpus = num_online_cpus() - 1;
- if (!num_cpus)
- goto done;

/* remove 'self' from the map */
if (cpu_isset(smp_processor_id(), map))
@@ -224,7 +219,9 @@ int smp_call_function_map(void (*func) (

/* sanity check the map, remove any non-online processors. */
cpus_and(map, map, cpu_online_map);
- if (cpus_empty(map))
+
+ num_cpus = cpus_weight(map);
+ if (!num_cpus)
goto done;

call_data = &data;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH][resubmit] x86: enable preemption in delay
    ... The difference is that in Steven's version the loop is running ... mainly with preemption disabled, except for: ... set the mask of allowed cpus to the current cpu only; ...
    (Linux-Kernel)
  • Re: [PATCH -tip/cpus4096-v2] cpumask: fix cpumask of call_function_data
    ... First path is when no online CPUs are in mask at all. ... * Ensure stack based data used in call function mask is safe to free. ... * hardware interrupt handler or from a bottom half handler. ...
    (Linux-Kernel)
  • Re: Linux compatible setaffinity.
    ... int cpuaffinity_getmax(scope, id, length, mask) ... Scope would be something on the order of process, id would be the id in that scope namespace, length and mask would be as you propose. ... Otherwise all cpus would be returned. ...
    (freebsd-arch)
  • Re: [PATCH 0/3] x86: add cpus_scnprintf function v3
    ... PAGE_SIZE buffer provided (though some pathological cases will overflow ... Worst case lists involve every other CPU or node (all the even ones, ... For CPUs or Nodes that take five decimal digits ... The corresponding mask ...
    (Linux-Kernel)
  • Re: Questions about porting perfmon2 to powerpc
    ... On Thu April 5 2007 3:32 pm, Kevin Corry wrote: ... Powerpc provides an smp_call_functionroutine to run a function on ... decide whether to run on a specific CPU or on all CPUs. ... * hardware interrupt handler or from a bottom half handler. ...
    (Linux-Kernel)