Skip to content

Commit

Permalink
[POWERPC] Fix num_cpus calculation in smp_call_function_map()
Browse files Browse the repository at this point in the history
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@us.ibm.com>
Signed-off-by: Carl Love <carll@us.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Kevin Corry authored and Paul Mackerras committed Aug 3, 2007
1 parent cba684f commit 17aa3a8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,16 @@ int smp_call_function_map(void (*func) (void *info), void *info, int nonatomic,
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))
cpu_clear(smp_processor_id(), map);

/* 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;
Expand Down

0 comments on commit 17aa3a8

Please sign in to comment.