Skip to content

Commit

Permalink
powerpc/xmon: Fix printing of set of CPUs in xmon
Browse files Browse the repository at this point in the history
Commit 24ec212 ("powerpc/xmon: Use cpumask iterator to avoid warning")
replaced a loop from 0 to NR_CPUS-1 with a for_each_possible_cpu() loop,
which means that if the last possible cpu is in xmon, we print the
wrong value for the end of the range.  For example, if 4 cpus are
possible, NR_CPUS is 128, and all cpus are in xmon, we print "0-7f"
rather than "0-3".  The code also assumes that the set of possible
cpus is contiguous, which may not necessarily be true.

This fixes the code to check explicitly for contiguity, and to print
the ending value correctly.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Paul Mackerras authored and Benjamin Herrenschmidt committed Sep 5, 2013
1 parent 91c2beb commit fd3bb91
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions arch/powerpc/xmon/xmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,27 +972,27 @@ static void bootcmds(void)
static int cpu_cmd(void)
{
#ifdef CONFIG_SMP
unsigned long cpu;
unsigned long cpu, first_cpu, last_cpu;
int timeout;
int count;

if (!scanhex(&cpu)) {
/* print cpus waiting or in xmon */
printf("cpus stopped:");
count = 0;
last_cpu = first_cpu = NR_CPUS;
for_each_possible_cpu(cpu) {
if (cpumask_test_cpu(cpu, &cpus_in_xmon)) {
if (count == 0)
printf(" %x", cpu);
++count;
} else {
if (count > 1)
printf("-%x", cpu - 1);
count = 0;
if (cpu == last_cpu + 1) {
last_cpu = cpu;
} else {
if (last_cpu != first_cpu)
printf("-%lx", last_cpu);
last_cpu = first_cpu = cpu;
printf(" %lx", cpu);
}
}
}
if (count > 1)
printf("-%x", NR_CPUS - 1);
if (last_cpu != first_cpu)
printf("-%lx", last_cpu);
printf("\n");
return 0;
}
Expand Down

0 comments on commit fd3bb91

Please sign in to comment.