Re: [PATCH] Print also the BSP number when announcing cpu

From: Dashi Cao
Date: Mon Mar 11 2024 - 01:26:39 EST


On Mon, 2024-03-11 at 12:39 +0800, Dashi Cao wrote:
> When announcing CPU, the BSP is always printed as blanks.
> This patch will print out the BSP number. It has the assumption
> that the BSP is not the last CPU in a CPU node.
>
> Dashi Cao
>
I'm sorry, the bsp should also be declared as static int, not int.

Dashi Cao

Signed-off-by: Dashi Cao <dscao999@xxxxxxxxx>
---
arch/x86/kernel/smpboot.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 3f57ce68a3f1..ef6e7a4bd020 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -931,7 +931,7 @@ static int wakeup_secondary_cpu_via_init(u32
phys_apicid, unsigned long start_ei
/* reduce the number of lines printed when booting a large cpu count
system */
static void announce_cpu(int cpu, int apicid)
{
- static int width, node_width, first = 1;
+ static int width, node_width, bsp, bspn = -1;
static int current_node = NUMA_NO_NODE;
int node = early_cpu_to_node(cpu);

@@ -942,7 +942,7 @@ static void announce_cpu(int cpu, int apicid)
node_width = num_digits(num_possible_nodes()) + 1; /* +
'#' */

if (system_state < SYSTEM_RUNNING) {
- if (first)
+ if (bspn == -1)
pr_info("x86: Booting SMP configuration:\n");

if (node != current_node) {
@@ -954,10 +954,12 @@ static void announce_cpu(int cpu, int apicid)
node_width - num_digits(node), " ",
node);
}

- /* Add padding for the BSP */
- if (first)
- pr_cont("%*s", width + 1, " ");
- first = 0;
+ if (bspn == -1) {
+ bsp = raw_smp_processor_id();
+ bspn = cpumask_next(bsp, cpu_present_mask);
+ }
+ if (cpu == bspn)
+ pr_cont("%*s#%d", width - num_digits(bsp), " ",
bsp);

pr_cont("%*s#%d", width - num_digits(cpu), " ", cpu);
} else
--
2.30.2