Skip to content

Commit

Permalink
x86/boot: Further compress CPUs bootup message
Browse files Browse the repository at this point in the history
Turn it into (for example):

[    0.073380] x86: Booting SMP configuration:
[    0.074005] .... node   #0, CPUs:          beagleboard#1   beagleboard#2   beagleboard#3   beagleboard#4   beagleboard#5   beagleboard#6   beagleboard#7
[    0.603005] .... node   beagleboard#1, CPUs:     beagleboard#8   beagleboard#9  beagleboard#10  beagleboard#11  beagleboard#12  beagleboard#13  beagleboard#14  beagleboard#15
[    1.200005] .... node   beagleboard#2, CPUs:    beagleboard#16  beagleboard#17  beagleboard#18  beagleboard#19  beagleboard#20  beagleboard#21  beagleboard#22  beagleboard#23
[    1.796005] .... node   beagleboard#3, CPUs:    beagleboard#24  beagleboard#25  beagleboard#26  beagleboard#27  beagleboard#28  beagleboard#29  beagleboard#30  beagleboard#31
[    2.393005] .... node   beagleboard#4, CPUs:    beagleboard#32  beagleboard#33  beagleboard#34  beagleboard#35  beagleboard#36  beagleboard#37  beagleboard#38  beagleboard#39
[    2.996005] .... node   beagleboard#5, CPUs:    beagleboard#40  beagleboard#41  beagleboard#42  beagleboard#43  beagleboard#44  beagleboard#45  beagleboard#46  beagleboard#47
[    3.600005] .... node   beagleboard#6, CPUs:    beagleboard#48  beagleboard#49  beagleboard#50  beagleboard#51  beagleboard#52  beagleboard#53  beagleboard#54  beagleboard#55
[    4.202005] .... node   beagleboard#7, CPUs:    beagleboard#56  beagleboard#57  beagleboard#58  beagleboard#59  beagleboard#60  beagleboard#61  beagleboard#62  beagleboard#63
[    4.811005] .... node   beagleboard#8, CPUs:    beagleboard#64  beagleboard#65  beagleboard#66  beagleboard#67  beagleboard#68  beagleboard#69  beagleboard#70  beagleboard#71
[    5.421006] .... node   beagleboard#9, CPUs:    beagleboard#72  beagleboard#73  beagleboard#74  beagleboard#75  beagleboard#76  beagleboard#77  beagleboard#78  beagleboard#79
[    6.032005] .... node  beagleboard#10, CPUs:    beagleboard#80  beagleboard#81  beagleboard#82  beagleboard#83  beagleboard#84  beagleboard#85  beagleboard#86  beagleboard#87
[    6.648006] .... node  beagleboard#11, CPUs:    beagleboard#88  beagleboard#89  beagleboard#90  beagleboard#91  beagleboard#92  beagleboard#93  beagleboard#94  beagleboard#95
[    7.262005] .... node  beagleboard#12, CPUs:    beagleboard#96  beagleboard#97  beagleboard#98  beagleboard#99 beagleboard#100 beagleboard#101 beagleboard#102 beagleboard#103
[    7.865005] .... node  beagleboard#13, CPUs:   beagleboard#104 beagleboard#105 beagleboard#106 beagleboard#107 beagleboard#108 beagleboard#109 beagleboard#110 beagleboard#111
[    8.466005] .... node  beagleboard#14, CPUs:   beagleboard#112 beagleboard#113 beagleboard#114 beagleboard#115 beagleboard#116 beagleboard#117 beagleboard#118 beagleboard#119
[    9.073006] .... node  beagleboard#15, CPUs:   beagleboard#120 beagleboard#121 beagleboard#122 beagleboard#123 beagleboard#124 beagleboard#125 beagleboard#126 beagleboard#127
[    9.679901] x86: Booted up 16 nodes, 128 CPUs

and drop useless elements.

Change num_digits() to hpa's division-avoiding, cell-phone-typed
version which he went at great lengths and pains to submit on a
Saturday evening.

Signed-off-by: Borislav Petkov <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Linus Torvalds <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
bp3tk0v authored and Ingo Molnar committed Oct 1, 2013
1 parent 646e29a commit a17bce4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
24 changes: 19 additions & 5 deletions arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,22 +647,38 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
return (send_status | accept_status);
}

void smp_announce(void)
{
int num_nodes = num_online_nodes();

printk(KERN_INFO "x86: Booted up %d node%s, %d CPUs\n",
num_nodes, (num_nodes > 1 ? "s" : ""), num_online_cpus());
}

/* reduce the number of lines printed when booting a large cpu count system */
static void announce_cpu(int cpu, int apicid)
{
static int current_node = -1;
int node = early_cpu_to_node(cpu);
static int width;
static int width, node_width;

if (!width)
width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */

if (!node_width)
node_width = num_digits(num_possible_nodes()) + 1; /* + '#' */

if (cpu == 1)
printk(KERN_INFO "x86: Booting SMP configuration:\n");

if (system_state == SYSTEM_BOOTING) {
if (node != current_node) {
if (current_node > (-1))
pr_cont(" OK\n");
pr_cont("\n");
current_node = node;
pr_info("Booting Node %3d, Processors:", node);

printk(KERN_INFO ".... node %*s#%d, CPUs: ",
node_width - num_digits(node), " ", node);
}

/* Add padding for the BSP */
Expand All @@ -671,8 +687,6 @@ static void announce_cpu(int cpu, int apicid)

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);
Expand Down
20 changes: 15 additions & 5 deletions arch/x86/lib/misc.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
/*
* Count the digits of @val including a possible sign.
*
* (Typed on and submitted from hpa's mobile phone.)
*/
int num_digits(int val)
{
int digits = 0;
int m = 10;
int d = 1;

while (val) {
val /= 10;
digits++;
if (val < 0) {
d++;
val = -val;
}

return digits;
while (val >= m) {
m *= 10;
d++;
}
return d;
}
7 changes: 6 additions & 1 deletion kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,11 @@ void __init setup_nr_cpu_ids(void)
nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1;
}

void __weak smp_announce(void)
{
printk(KERN_INFO "Brought up %d CPUs\n", num_online_cpus());
}

/* Called by boot processor to activate the rest. */
void __init smp_init(void)
{
Expand All @@ -540,7 +545,7 @@ void __init smp_init(void)
}

/* Any cleanup work */
printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
smp_announce();
smp_cpus_done(setup_max_cpus);
}

Expand Down

0 comments on commit a17bce4

Please sign in to comment.