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 torvalds#10 torvalds#11 torvalds#12 torvalds#13 torvalds#14 torvalds#15 OK [ 1.245006] smpboot: Booting Node 2, Processors: torvalds#16 torvalds#17 torvalds#18 torvalds#19 torvalds#20 torvalds#21 torvalds#22 torvalds#23 OK [ 1.864005] smpboot: Booting Node 3, Processors: torvalds#24 torvalds#25 torvalds#26 torvalds#27 torvalds#28 torvalds#29 torvalds#30 torvalds#31 OK [ 2.489005] smpboot: Booting Node 4, Processors: torvalds#32 torvalds#33 torvalds#34 torvalds#35 torvalds#36 torvalds#37 torvalds#38 torvalds#39 OK [ 3.093005] smpboot: Booting Node 5, Processors: torvalds#40 torvalds#41 torvalds#42 torvalds#43 torvalds#44 torvalds#45 torvalds#46 torvalds#47 OK [ 3.698005] smpboot: Booting Node 6, Processors: torvalds#48 torvalds#49 torvalds#50 torvalds#51 #52 #53 torvalds#54 torvalds#55 OK [ 4.304005] smpboot: Booting Node 7, Processors: torvalds#56 torvalds#57 #58 torvalds#59 torvalds#60 torvalds#61 torvalds#62 torvalds#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

+6
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

+15-6
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

+1-1
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

+11
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)