Skip to content

Commit 646e29a

Browse files
suryasaimadhuIngo Molnar
authored and
Ingo Molnar
committed
x86: Improve the printout of the SMP bootup CPU table
As the new x86 CPU bootup printout format code maintainer, I am taking immediate action to improve and clean (and thus indulge my OCD) the reporting of the cores when coming up online. Fix padding to a right-hand alignment, cleanup code and bind reporting width to the max number of supported CPUs on the system, like this: [ 0.074509] smpboot: Booting Node 0, Processors: #1 #2 #3 #4 #5 #6 #7 OK [ 0.644008] smpboot: Booting Node 1, Processors: #8 #9 #10 #11 #12 #13 #14 #15 OK [ 1.245006] smpboot: Booting Node 2, Processors: #16 raspberrypi#17 raspberrypi#18 raspberrypi#19 raspberrypi#20 raspberrypi#21 raspberrypi#22 raspberrypi#23 OK [ 1.864005] smpboot: Booting Node 3, Processors: raspberrypi#24 raspberrypi#25 raspberrypi#26 raspberrypi#27 raspberrypi#28 raspberrypi#29 raspberrypi#30 raspberrypi#31 OK [ 2.489005] smpboot: Booting Node 4, Processors: raspberrypi#32 raspberrypi#33 raspberrypi#34 raspberrypi#35 raspberrypi#36 raspberrypi#37 raspberrypi#38 raspberrypi#39 OK [ 3.093005] smpboot: Booting Node 5, Processors: raspberrypi#40 raspberrypi#41 raspberrypi#42 raspberrypi#43 raspberrypi#44 raspberrypi#45 raspberrypi#46 raspberrypi#47 OK [ 3.698005] smpboot: Booting Node 6, Processors: raspberrypi#48 raspberrypi#49 raspberrypi#50 raspberrypi#51 raspberrypi#52 raspberrypi#53 raspberrypi#54 raspberrypi#55 OK [ 4.304005] smpboot: Booting Node 7, Processors: raspberrypi#56 raspberrypi#57 raspberrypi#58 raspberrypi#59 raspberrypi#60 raspberrypi#61 raspberrypi#62 raspberrypi#63 OK [ 4.961413] Brought up 64 CPUs and this: [ 0.072367] smpboot: Booting Node 0, Processors: #1 #2 #3 #4 #5 #6 #7 OK [ 0.686329] Brought up 8 CPUs Signed-off-by: Borislav Petkov <[email protected]> Cc: Libin <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 6cac446 commit 646e29a

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

arch/x86/include/asm/misc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _ASM_X86_MISC_H
2+
#define _ASM_X86_MISC_H
3+
4+
int num_digits(int val);
5+
6+
#endif /* _ASM_X86_MISC_H */

arch/x86/kernel/smpboot.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@
7373
#include <asm/setup.h>
7474
#include <asm/uv/uv.h>
7575
#include <linux/mc146818rtc.h>
76-
7776
#include <asm/smpboot_hooks.h>
7877
#include <asm/i8259.h>
79-
8078
#include <asm/realmode.h>
79+
#include <asm/misc.h>
8180

8281
/* State of each CPU */
8382
DEFINE_PER_CPU(int, cpu_state) = { 0 };
@@ -653,17 +652,27 @@ static void announce_cpu(int cpu, int apicid)
653652
{
654653
static int current_node = -1;
655654
int node = early_cpu_to_node(cpu);
656-
int max_cpu_present = find_last_bit(cpumask_bits(cpu_present_mask), NR_CPUS);
655+
static int width;
656+
657+
if (!width)
658+
width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
657659

658660
if (system_state == SYSTEM_BOOTING) {
659661
if (node != current_node) {
660662
if (current_node > (-1))
661663
pr_cont(" OK\n");
662664
current_node = node;
663-
pr_info("Booting Node %3d, Processors ", node);
665+
pr_info("Booting Node %3d, Processors:", node);
664666
}
665-
pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
666-
return;
667+
668+
/* Add padding for the BSP */
669+
if (cpu == 1)
670+
pr_cont("%*s", width + 1, " ");
671+
672+
pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu);
673+
674+
if (cpu == num_present_cpus() - 1)
675+
pr_cont(" OK\n");
667676
} else
668677
pr_info("Booting Node %d Processor %d APIC 0x%x\n",
669678
node, cpu, apicid);

arch/x86/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ clean-files := inat-tables.c
1616

1717
obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o
1818

19-
lib-y := delay.o
19+
lib-y := delay.o misc.o
2020
lib-y += thunk_$(BITS).o
2121
lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
2222
lib-y += memcpy_$(BITS).o

arch/x86/lib/misc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
int num_digits(int val)
2+
{
3+
int digits = 0;
4+
5+
while (val) {
6+
val /= 10;
7+
digits++;
8+
}
9+
10+
return digits;
11+
}

0 commit comments

Comments
 (0)