aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2013-09-03 06:16:23 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-09-05 03:29:19 -0400
commitfd3bb91287b600d8b389c159e8dd96391410087b (patch)
tree02229ae5302d089f349ae9a6740a800bb45f322a /arch
parent91c2beb56b3ab5cf91fe04ddaeb69b90a22b5d36 (diff)
powerpc/xmon: Fix printing of set of CPUs in xmon
Commit 24ec2125f3 ("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>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/xmon/xmon.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 9f3655be695d..af9d3469fb99 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -972,27 +972,27 @@ static void bootcmds(void)
972static int cpu_cmd(void) 972static int cpu_cmd(void)
973{ 973{
974#ifdef CONFIG_SMP 974#ifdef CONFIG_SMP
975 unsigned long cpu; 975 unsigned long cpu, first_cpu, last_cpu;
976 int timeout; 976 int timeout;
977 int count;
978 977
979 if (!scanhex(&cpu)) { 978 if (!scanhex(&cpu)) {
980 /* print cpus waiting or in xmon */ 979 /* print cpus waiting or in xmon */
981 printf("cpus stopped:"); 980 printf("cpus stopped:");
982 count = 0; 981 last_cpu = first_cpu = NR_CPUS;
983 for_each_possible_cpu(cpu) { 982 for_each_possible_cpu(cpu) {
984 if (cpumask_test_cpu(cpu, &cpus_in_xmon)) { 983 if (cpumask_test_cpu(cpu, &cpus_in_xmon)) {
985 if (count == 0) 984 if (cpu == last_cpu + 1) {
986 printf(" %x", cpu); 985 last_cpu = cpu;
987 ++count; 986 } else {
988 } else { 987 if (last_cpu != first_cpu)
989 if (count > 1) 988 printf("-%lx", last_cpu);
990 printf("-%x", cpu - 1); 989 last_cpu = first_cpu = cpu;
991 count = 0; 990 printf(" %lx", cpu);
991 }
992 } 992 }
993 } 993 }
994 if (count > 1) 994 if (last_cpu != first_cpu)
995 printf("-%x", NR_CPUS - 1); 995 printf("-%lx", last_cpu);
996 printf("\n"); 996 printf("\n");
997 return 0; 997 return 0;
998 } 998 }