diff --git a/arch/x86/include/asm/misc.h b/arch/x86/include/asm/misc.h new file mode 100644 index 00000000000000..475f5bbc7f53dc --- /dev/null +++ b/arch/x86/include/asm/misc.h @@ -0,0 +1,6 @@ +#ifndef _ASM_X86_MISC_H +#define _ASM_X86_MISC_H + +int num_digits(int val); + +#endif /* _ASM_X86_MISC_H */ diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 6cacab671f9b76..d41f3ba26ced27 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -73,11 +73,10 @@ #include #include #include - #include #include - #include +#include /* State of each CPU */ DEFINE_PER_CPU(int, cpu_state) = { 0 }; @@ -653,17 +652,27 @@ static void announce_cpu(int cpu, int apicid) { static int current_node = -1; int node = early_cpu_to_node(cpu); - int max_cpu_present = find_last_bit(cpumask_bits(cpu_present_mask), NR_CPUS); + static int width; + + if (!width) + width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */ if (system_state == SYSTEM_BOOTING) { if (node != current_node) { if (current_node > (-1)) pr_cont(" OK\n"); current_node = node; - pr_info("Booting Node %3d, Processors ", node); + pr_info("Booting Node %3d, Processors:", node); } - pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : ""); - return; + + /* Add padding for the BSP */ + if (cpu == 1) + pr_cont("%*s", width + 1, " "); + + pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu); + + if (cpu == num_present_cpus() - 1) + pr_cont(" OK\n"); } else pr_info("Booting Node %d Processor %d APIC 0x%x\n", node, cpu, apicid); diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 96b2c6697c9d9b..992d63bb154f0e 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -16,7 +16,7 @@ clean-files := inat-tables.c obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o -lib-y := delay.o +lib-y := delay.o misc.o lib-y += thunk_$(BITS).o lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o lib-y += memcpy_$(BITS).o diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c new file mode 100644 index 00000000000000..bc35cde9769f18 --- /dev/null +++ b/arch/x86/lib/misc.c @@ -0,0 +1,11 @@ +int num_digits(int val) +{ + int digits = 0; + + while (val) { + val /= 10; + digits++; + } + + return digits; +}