Skip to contentSkip to conversation

x86, smpboot: fix announce_cpu() to print the last OK

PATCH In review Libin 8 participants 46 messages Sep 5, 2013 – Oct 2, 2013 x86

lore
Share & tools
lore

Libin

author
#0 lore raw

PATCH 1/1 x86, smpboot: fix announce_cpu() to print the last OK

When booting cpu, announce_cpu() is called to show which cpu is up as following:

[    0.402751] smpboot: Booting Node   0, Processors  #1 #2 #3 #4 #5 OK
[    0.525667] smpboot: Booting Node   1, Processors  #6 #7 #8 #9 #10 #11 OK
[    0.755592] smpboot: Booting Node   0, Processors  #12 #13 #14 #15 #16 #17 OK
[    0.890495] smpboot: Booting Node   1, Processors  #18 #19 #20 #21 #22 #23

But the last OK is lost, because 'nr_cpu_ids-1' represents the maxinum possible cpu id. It should use the maxinum present cpu id.

---
 arch/x86/kernel/smpboot.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +3 -1
index aecc98a..549b8cb 100644
@@ -653,6 +653,8 @@ 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);
 
 	if (system_state == SYSTEM_BOOTING) {
 		if (node != current_node) {
@@ -661,7 +663,7 @@ static void announce_cpu(int cpu, int apicid)
 			current_node = node;
 			pr_info("Booting Node %3d, Processors ", node);
 		}
-		pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " OK\n" : "");
+		pr_cont(" #%d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
 		return;
 	} else
 		pr_info("Booting Node %d Processor %d APIC 0x%x\n",
Signature · 1 line
1.8.2.1
#1 lore raw

[tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly
Commit-ID:  52239484bf8aec031afa84ae08aa88224d819b93
Gitweb:     http://git.kernel.org/tip/52239484bf8aec031afa84ae08aa88224d819b93
Author:     Libin <[email protected]>
AuthorDate: Thu, 5 Sep 2013 18:57:56 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 Sep 2013 15:05:37 +0200

x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

When booting secondary CPUs, announce_cpu() is called to show which cpu has been brought up. For example:

[    0.402751] smpboot: Booting Node   0, Processors  #1 #2 #3 #4 #5 OK
[    0.525667] smpboot: Booting Node   1, Processors  #6 #7 #8 #9 #10 #11 OK
[    0.755592] smpboot: Booting Node   0, Processors  #12 #13 #14 #15 #16 #17 OK
[    0.890495] smpboot: Booting Node   1, Processors  #18 #19 #20 #21 #22 #23

But the last "OK" is lost, because 'nr_cpu_ids-1' represents the maximum possible cpu id. It should use the maximum present cpu id in case not all CPUs booted up.

[ tweaked the changelog, removed unnecessary line break, tweaked the format to align the fields vertically. ]
---
 arch/x86/kernel/smpboot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/smpboot.c +2 -1
index aecc98a..6cacab6 100644
@@ -653,6 +653,7 @@ 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);
 
 	if (system_state == SYSTEM_BOOTING) {
 		if (node != current_node) {
@@ -661,7 +662,7 @@ static void announce_cpu(int cpu, int apicid)
 			current_node = node;
 			pr_info("Booting Node %3d, Processors ", node);
 		}
-		pr_cont(" #%d%s", cpu, cpu == (nr_cpu_ids - 1) ? " OK\n" : "");
+		pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
 		return;
 	} else
 		pr_info("Booting Node %d Processor %d APIC 0x%x\n",
maintainer
#2 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

Quoted 21 lines · tip-bot for Libin
Commit-ID:  52239484bf8aec031afa84ae08aa88224d819b93
Gitweb:     http://git.kernel.org/tip/52239484bf8aec031afa84ae08aa88224d819b93
Author:     Libin <[email protected]>
AuthorDate: Thu, 5 Sep 2013 18:57:56 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 Sep 2013 15:05:37 +0200

x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

When booting secondary CPUs, announce_cpu() is called to show which cpu has been brought up. For example:

[    0.402751] smpboot: Booting Node   0, Processors  #1 #2 #3 #4 #5 OK
[    0.525667] smpboot: Booting Node   1, Processors  #6 #7 #8 #9 #10 #11 OK
[    0.755592] smpboot: Booting Node   0, Processors  #12 #13 #14 #15 #16 #17 OK
[    0.890495] smpboot: Booting Node   1, Processors  #18 #19 #20 #21 #22 #23

But the last "OK" is lost, because 'nr_cpu_ids-1' represents the maximum possible cpu id. It should use the maximum present cpu id in case not all CPUs booted up.

Quoted 8 lines
[ tweaked the changelog, removed unnecessary line break, tweaked the format to align the fields vertically. ]

Hmm, this one kinda funnied up output on smaller boxes:

[    0.089340] smpboot: Booting Node   0, Processors  #   1
[    0.105930] SMP alternatives: lockdep: fixing up alternatives
[    0.106073]  #   2
[    0.122237] SMP alternatives: lockdep: fixing up alternatives
[    0.122384]  #   3 OK
[    0.136464] Brought up 4 CPUs
[    0.136539] smpboot: Total of 4 processors activated (23146.40 BogoMIPS)

Thanks.

#3 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

Quoted 33 lines · Borislav Petkov
Quoted 21 lines · tip-bot for Libin
Commit-ID:  52239484bf8aec031afa84ae08aa88224d819b93
Gitweb:     http://git.kernel.org/tip/52239484bf8aec031afa84ae08aa88224d819b93
Author:     Libin <[email protected]>
AuthorDate: Thu, 5 Sep 2013 18:57:56 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 5 Sep 2013 15:05:37 +0200

x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

When booting secondary CPUs, announce_cpu() is called to show which cpu has been brought up. For example:

[    0.402751] smpboot: Booting Node   0, Processors  #1 #2 #3 #4 #5 OK
[    0.525667] smpboot: Booting Node   1, Processors  #6 #7 #8 #9 #10 #11 OK
[    0.755592] smpboot: Booting Node   0, Processors  #12 #13 #14 #15 #16 #17 OK
[    0.890495] smpboot: Booting Node   1, Processors  #18 #19 #20 #21 #22 #23

But the last "OK" is lost, because 'nr_cpu_ids-1' represents the maximum possible cpu id. It should use the maximum present cpu id in case not all CPUs booted up.

Quoted 8 lines
[ tweaked the changelog, removed unnecessary line break, tweaked the format to align the fields vertically. ]

Hmm, this one kinda funnied up output on smaller boxes:

Quoted 7 lines
[    0.089340] smpboot: Booting Node   0, Processors  #   1
[    0.105930] SMP alternatives: lockdep: fixing up alternatives
[    0.106073]  #   2
[    0.122237] SMP alternatives: lockdep: fixing up alternatives
[    0.122384]  #   3 OK
[    0.136464] Brought up 4 CPUs
[    0.136539] smpboot: Total of 4 processors activated (23146.40 BogoMIPS)

Indeed, that should be fixed.

Thanks,

Ingo

maintainer
#4 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

Quoted 1 line · Ingo Molnar

Indeed, that should be fixed.

Ok, how does a right alighment look like:

[    0.072399] smpboot: Booting Node   0, Processors   #1   #2   #3   #4   #5   #6   #7 OK
[    0.617005] smpboot: Booting Node   1, Processors   #8   #9  #10  #11  #12  #13  #14  #15 OK
[    1.230005] smpboot: Booting Node   2, Processors  #16  #17  #18  #19  #20  #21  #22  #23 OK
[    1.835005] smpboot: Booting Node   3, Processors  #24  #25  #26  #27  #28  #29  #30  #31 OK
[    2.437005] smpboot: Booting Node   4, Processors  #32  #33  #34  #35  #36  #37  #38  #39 OK
[    3.053005] smpboot: Booting Node   5, Processors  #40  #41  #42  #43  #44  #45  #46  #47 OK
[    3.657009] smpboot: Booting Node   6, Processors  #48  #49  #50  #51  #52  #53  #54  #55 OK
[    4.256005] smpboot: Booting Node   7, Processors  #56  #57  #58  #59  #60  #61  #62  #63 OK

?

With lockdep butting in-between it is still readable:

[    0.063330] SMP alternatives: lockdep: fixing up alternatives
[    0.064032] smpboot: Booting Node   0, Processors   #1
[    0.141231] SMP alternatives: lockdep: fixing up alternatives
[    0.142007]    #2
[    0.230210] SMP alternatives: lockdep: fixing up alternatives
[    0.231007]    #3
[    0.307237] SMP alternatives: lockdep: fixing up alternatives
[    0.308007]    #4
[    0.384231] SMP alternatives: lockdep: fixing up alternatives
[    0.385006]    #5
[    0.468237] SMP alternatives: lockdep: fixing up alternatives
[    0.469007]    #6
[    0.545230] SMP alternatives: lockdep: fixing up alternatives
[    0.546006]    #7 OK
[    0.626323] Brought up 8 CPUs
[    0.627004] smpboot: Total of 8 processors activated (64217.00 BogoMIPS)

I admit the digits calculation is a bit clumsy but I didn't want to do any log_10 crazy jumps through hoops and besides, it should be faster this way:

--

arch/x86/kernel/smpboot.c +9 -3
index 6cacab671f9b..1cf5957b1035 100644
@@ -653,16 +653,22 @@ 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);
+	int num_digits;
 
 	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" : "");
+		num_digits = 1 + 1 * (cpu > 9) + 1 * (cpu > 99);
+
+		pr_cont("%*s#%d", 4 - num_digits, " ", cpu);
+
+		if (cpu == num_present_cpus() - 1)
+			pr_cont(" OK\n");
+
 		return;
 	} else
 		pr_info("Booting Node %d Processor %d APIC 0x%x\n",

--

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#5 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

Quoted 14 lines · Borislav Petkov
Quoted 1 line · Ingo Molnar

Indeed, that should be fixed.

Ok, how does a right alighment look like:

[    0.072399] smpboot: Booting Node   0, Processors   #1   #2   #3   #4   #5   #6   #7 OK
[    0.617005] smpboot: Booting Node   1, Processors   #8   #9  #10  #11  #12  #13  #14  #15 OK
[    1.230005] smpboot: Booting Node   2, Processors  #16  #17  #18  #19  #20  #21  #22  #23 OK
[    1.835005] smpboot: Booting Node   3, Processors  #24  #25  #26  #27  #28  #29  #30  #31 OK
[    2.437005] smpboot: Booting Node   4, Processors  #32  #33  #34  #35  #36  #37  #38  #39 OK
[    3.053005] smpboot: Booting Node   5, Processors  #40  #41  #42  #43  #44  #45  #46  #47 OK
[    3.657009] smpboot: Booting Node   6, Processors  #48  #49  #50  #51  #52  #53  #54  #55 OK
[    4.256005] smpboot: Booting Node   7, Processors  #56  #57  #58  #59  #60  #61  #62  #63 OK
Quoted 1 line

?

Looks cool. The perfectionist in me would love to skip CPU0's space so that we get:

[    0.072399] smpboot: Booting Node   0, Processors        #1   #2   #3   #4   #5   #6   #7 OK
[    0.617005] smpboot: Booting Node   1, Processors   #8   #9  #10  #11  #12  #13  #14  #15 OK
[    1.230005] smpboot: Booting Node   2, Processors  #16  #17  #18  #19  #20  #21  #22  #23 OK
[    1.835005] smpboot: Booting Node   3, Processors  #24  #25  #26  #27  #28  #29  #30  #31 OK
[    2.437005] smpboot: Booting Node   4, Processors  #32  #33  #34  #35  #36  #37  #38  #39 OK

Pretty please? :-)

Quoted 18 lines

With lockdep butting in-between it is still readable:

[    0.063330] SMP alternatives: lockdep: fixing up alternatives
[    0.064032] smpboot: Booting Node   0, Processors   #1
[    0.141231] SMP alternatives: lockdep: fixing up alternatives
[    0.142007]    #2
[    0.230210] SMP alternatives: lockdep: fixing up alternatives
[    0.231007]    #3
[    0.307237] SMP alternatives: lockdep: fixing up alternatives
[    0.308007]    #4
[    0.384231] SMP alternatives: lockdep: fixing up alternatives
[    0.385006]    #5
[    0.468237] SMP alternatives: lockdep: fixing up alternatives
[    0.469007]    #6
[    0.545230] SMP alternatives: lockdep: fixing up alternatives
[    0.546006]    #7 OK
[    0.626323] Brought up 8 CPUs
[    0.627004] smpboot: Total of 8 processors activated (64217.00 BogoMIPS)

Hm, I realize that this was a nice test for the printout robustness, but could you please also remove the alternatives message in another patch?

That message was cool and interesting back in the days when we wrote lockdep ('hey, look ma, it really works!!'), but there hasn't been any breakage in that area for a long time and it definitely does not deserve one line of log spam per CPU! Especially if it messes up such a nice CPU bootup table.

arch/x86/kernel/smpboot.c static void announce_cpu(int cpu, int apicid) · line 670

Quoted 11 lines

I admit the digits calculation is a bit clumsy but I didn't want to do any log_10 crazy jumps through hoops and besides, it should be faster this way:

arch/x86/kernel/smpboot.c +6 -1
-		pr_cont(" #%4d%s", cpu, cpu == max_cpu_present ? " OK\n" : "");
+		num_digits = 1 + 1 * (cpu > 9) + 1 * (cpu > 99);
+
+		pr_cont("%*s#%d", 4 - num_digits, " ", cpu);
+
+		if (cpu == num_present_cpus() - 1)
+			pr_cont(" OK\n");

So how about taking log10(num_possible_cpus()) as the width of the printout? (If it wraps out of the screen on 4K CPU systems then those lucky people can resize their terminals or so.)

There's absolutely no speed consideration here, and people do keep staring at the CPU bootup printout frequently. A small helper function can construct a fixed-width entry into a string, which can be printed using %s.

Width only has to be calculated once:

static int num_digits(val)

{
	int digits = 0;

	while (val) {
		val /= 10;
		digits++;
	}

	return digits;
}

...

	width = num_digits(num_possible_cpus());

...

And the beauty of it is that small, slow systems will naturally spend a few cycles less time in num_digits() than large, fast systems.

(and I hope you learned the lesson about sending improvement patches against long-bitrotten code, as the new x86 CPU bootup printout format code maintainer!)

Thanks,

Ingo

maintainer
#6 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

On Fri, Sep 27, 2013 at 08:51:15AM +0200, Ingo Molnar wrote:

<snip stuff to do>

Quoted 3 lines

(and I hope you learned the lesson about sending improvement patches against long-bitrotten code, as the new x86 CPU bootup printout format code maintainer!)

Oh shit, what did I get into!? I only wanted to do a quick fix and get back to the real, manly bugs!

:-) :-) :-)

Ok, I'll do all that you suggested and send you the results.

Btw, qemu is so cool in generating the craziest topologies and much easier than me actually going and looking for such a real big system:

kvm -smp 64 \
-numa node,nodeid=0,cpus=0-7 \
-numa node,nodeid=1,cpus=8-15 \
-numa node,nodeid=2,cpus=16-23 \
-numa node,nodeid=3,cpus=24-31 \
-numa node,nodeid=4,cpus=32-39 \
-numa node,nodeid=5,cpus=40-47 \
-numa node,nodeid=6,cpus=48-55 \
-numa node,nodeid=7,cpus=56-63 ...

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
maintainer
#7 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

Quoted 7 lines · Borislav Petkov

On Fri, Sep 27, 2013 at 08:51:15AM +0200, Ingo Molnar wrote:

<snip stuff to do>

Quoted 3 lines

(and I hope you learned the lesson about sending improvement patches against long-bitrotten code, as the new x86 CPU bootup printout format code maintainer!)

Ok, here it is:

[    0.075410] smpboot: Booting Node   0, Processors:      #1  #2  #3  #4  #5  #6  #7 OK
[    0.645005] smpboot: Booting Node   1, Processors:  #8  #9 #10 #11 #12 #13 #14 #15 OK
[    1.251005] smpboot: Booting Node   2, Processors: #16 #17 #18 #19 #20 #21 #22 #23 OK
[    1.853005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 #30 #31 OK
[    2.455005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 #38 #39 OK
[    3.074005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 #46 #47 OK
[    3.700005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 #54 #55 OK
[    4.320005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 #62 #63 OK
[    4.945472] Brought up 64 CPUs

smaller boxes:

[    0.072367] smpboot: Booting Node   0, Processors:    #1 #2 #3 #4 #5 #6 #7 OK
[    0.686329] Brought up 8 CPUs

Libin, I'd appreciate it if you run the following patches on your box to make sure everything is still ok.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
maintainer
#8 lore raw

PATCH 1/2 x86, alternatives: Drop ancient lockdep fixup message

From: Borislav Petkov <[email protected]>

It messes up the output of the nodes/cores bootup table and it is obsolete anyway, see

17abecfe651c x86: fix up alternatives with lockdep enabled

---
 arch/x86/kernel/alternative.c | 11 -----------
 1 file changed, 11 deletions(-)
arch/x86/kernel/alternative.c +0 -11
index 15e8563e5c24..df94598ad05a 100644
@@ -402,17 +402,6 @@ void alternatives_enable_smp(void)
 {
 	struct smp_alt_module *mod;
 
-#ifdef CONFIG_LOCKDEP
-	/*
-	 * Older binutils section handling bug prevented
-	 * alternatives-replacement from working reliably.
-	 *
-	 * If this still occurs then you should see a hang
-	 * or crash shortly after this line:
-	 */
-	pr_info("lockdep: fixing up alternatives\n");
-#endif
-
 	/* Why bother if there are no other CPUs? */
 	BUG_ON(num_possible_cpus() == 1);
 
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#9 lore raw

[tip:core/locking] lockdep, x86/alternatives: Drop ancient lockdep fixup message

lockdep, x86/alternatives: Drop ancient lockdep fixup message
Commit-ID:  2a929242ee50db84c1a561c81897bb0551f2c32f
Gitweb:     http://git.kernel.org/tip/2a929242ee50db84c1a561c81897bb0551f2c32f
Author:     Borislav Petkov <[email protected]>
AuthorDate: Fri, 27 Sep 2013 16:34:42 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 28 Sep 2013 10:09:41 +0200

lockdep, x86/alternatives: Drop ancient lockdep fixup message

It messes up the output of the nodes/cores bootup table and it is obsolete anyway, see

17abecfe651c x86: fix up alternatives with lockdep enabled

---
 arch/x86/kernel/alternative.c | 11 -----------
 1 file changed, 11 deletions(-)
arch/x86/kernel/alternative.c +0 -11
index 15e8563..df94598 100644
@@ -402,17 +402,6 @@ void alternatives_enable_smp(void)
 {
 	struct smp_alt_module *mod;
 
-#ifdef CONFIG_LOCKDEP
-	/*
-	 * Older binutils section handling bug prevented
-	 * alternatives-replacement from working reliably.
-	 *
-	 * If this still occurs then you should see a hang
-	 * or crash shortly after this line:
-	 */
-	pr_info("lockdep: fixing up alternatives\n");
-#endif
-
 	/* Why bother if there are no other CPUs? */
 	BUG_ON(num_possible_cpus() == 1);
 
maintainer
#10 lore raw

PATCH 2/2 x86: Cleanup boot CPUs table

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

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 #17 #18 #19 #20 #21 #22 #23 OK
[    1.864005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 #30 #31 OK
[    2.489005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 #38 #39 OK
[    3.093005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 #46 #47 OK
[    3.698005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 #54 #55 OK
[    4.304005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 #62 #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
---
 arch/x86/include/asm/misc.h |  6 ++++++
 arch/x86/kernel/smpboot.c   | 21 +++++++++++++++------
 arch/x86/lib/Makefile       |  2 +-
 arch/x86/lib/misc.c         | 11 +++++++++++
 4 files changed, 33 insertions(+), 7 deletions(-)
 create mode 100644 arch/x86/include/asm/misc.h
 create mode 100644 arch/x86/lib/misc.c
arch/x86/include/asm/misc.h new file +6 -0
new file mode 100644
index 000000000000..475f5bbc7f53
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
arch/x86/kernel/smpboot.c +15 -6
index 6cacab671f9b..d41f3ba26ced 100644
@@ -73,11 +73,10 @@
 #include <asm/setup.h>
 #include <asm/uv/uv.h>
 #include <linux/mc146818rtc.h>
-
 #include <asm/smpboot_hooks.h>
 #include <asm/i8259.h>
-
 #include <asm/realmode.h>
+#include <asm/misc.h>
 
 /* 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);
arch/x86/lib/Makefile +1 -1
index 96b2c6697c9d..992d63bb154f 100644
@@ -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
arch/x86/lib/misc.c new file +11 -0
new file mode 100644
index 000000000000..bc35cde9769f
@@ -0,0 +1,11 @@
+int num_digits(int val)
+{
+	int digits = 0;
+
+	while (val) {
+		val /= 10;
+		digits++;
+	}
+
+	return digits;
+}
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#11 lore raw

Re: [PATCH 2/2] x86: Cleanup boot CPUs table

Quoted 9 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

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:

Quoted 9 lines
[    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 #17 #18 #19 #20 #21 #22 #23 OK
[    1.864005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 #30 #31 OK
[    2.489005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 #38 #39 OK
[    3.093005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 #46 #47 OK
[    3.698005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 #54 #55 OK
[    4.304005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 #62 #63 OK
[    4.961413] Brought up 64 CPUs

Awesome!

Could we, with another add-on patch, further compress the first half of the output as well?

Advanced output like this would be really cool:

Quoted 9 lines
[    0.074509] x86: Booting node #0, CPUs:       #1  #2  #3  #4  #5  #6  #7
[    0.644008] x86: Booting node #1, CPUs:   #8  #9 #10 #11 #12 #13 #14 #15
[    1.245006] x86: Booting node #2, CPUs:  #16 #17 #18 #19 #20 #21 #22 #23
[    1.864005] x86: Booting node #3, CPUs:  #24 #25 #26 #27 #28 #29 #30 #31
[    2.489005] x86: Booting node #4, CPUs:  #32 #33 #34 #35 #36 #37 #38 #39
[    3.093005] x86: Booting node #5, CPUs:  #40 #41 #42 #43 #44 #45 #46 #47
[    3.698005] x86: Booting node #6, CPUs:  #48 #49 #50 #51 #52 #53 #54 #55
[    4.304005] x86: Booting node #7, CPUs:  #56 #57 #58 #59 #60 #61 #62 #63
[    4.961413] x86: Booted up 8 nodes, 64 CPUs

and:

Quoted 2 lines
[    0.072367] x86: Booting node #0, CPUs:     #1 #2 #3 #4 #5 #6 #7 
[    0.686329] x86: Booted up 1 node, 8 CPUs

Note the typographical details I added:

- I added an extra space after 'CPUs:' to make the table stand out better from far away

- Removed the 'OK' - it really does not add any more information than the newline already does

- Changed the 'Brought up' message to be more consistent with the prior messages.

- Added nodes count to the 'Booted up' line. Since we count nodes and CPUs, we might as well want to demonstrate our superior counting skills and print out both.

- The 'node' counting uses the new num_digits() function - this was very easy to implement in my mockup ;-)

- Note the singular spelling of 'node' in the 1-node case. Again this was easy in the mockup!

Thanks,

Ingo

maintainer
#12 lore raw

Re: [PATCH 2/2] x86: Cleanup boot CPUs table

Quoted 4 lines · Ingo Molnar

Could we, with another add-on patch, further compress the first half of the output as well?

Advanced output like this would be really cool:

Sure.

Quoted 9 lines
Quoted 9 lines
[    0.074509] x86: Booting node #0, CPUs:       #1  #2  #3  #4  #5  #6  #7
[    0.644008] x86: Booting node #1, CPUs:   #8  #9 #10 #11 #12 #13 #14 #15
[    1.245006] x86: Booting node #2, CPUs:  #16 #17 #18 #19 #20 #21 #22 #23
[    1.864005] x86: Booting node #3, CPUs:  #24 #25 #26 #27 #28 #29 #30 #31
[    2.489005] x86: Booting node #4, CPUs:  #32 #33 #34 #35 #36 #37 #38 #39
[    3.093005] x86: Booting node #5, CPUs:  #40 #41 #42 #43 #44 #45 #46 #47
[    3.698005] x86: Booting node #6, CPUs:  #48 #49 #50 #51 #52 #53 #54 #55
[    4.304005] x86: Booting node #7, CPUs:  #56 #57 #58 #59 #60 #61 #62 #63
[    4.961413] x86: Booted up 8 nodes, 64 CPUs

Boot(ing|ed) kinda wastes unnecessary space too, how about we go a step further:

[    0.074509] x86: Booting SMP configuration:
[    0.644008] .... node #0, CPUs:       #1  #2  #3  #4  #5  #6  #7
[    1.245006] .... node #1, CPUs:   #8  #9 #10 #11 #12 #13 #14 #15
[    1.864005] .... node #2, CPUs:  #16 #17 #18 #19 #20 #21 #22 #23
[    2.489005] .... node #3, CPUs:  #24 #25 #26 #27 #28 #29 #30 #31
[    3.093005] .... node #4, CPUs:  #32 #33 #34 #35 #36 #37 #38 #39
[    3.698005] .... node #5, CPUs:  #40 #41 #42 #43 #44 #45 #46 #47
[    4.304005] .... node #6, CPUs:  #48 #49 #50 #51 #52 #53 #54 #55
[    4.961413] .... node #7, CPUs:  #56 #57 #58 #59 #60 #61 #62 #63
[    5.245021] x86: Booted up 8 nodes, 64 CPUs
Quoted 2 lines
Quoted 2 lines
[    0.072367] x86: Booting node #0, CPUs:     #1 #2 #3 #4 #5 #6 #7 
[    0.686329] x86: Booted up 1 node, 8 CPUs

vs

[    0.074509] x86: Booting SMP configuration:
[    0.072367] .... node #0, CPUs:     #1 #2 #3 #4 #5 #6 #7
[    0.686329] x86: Booted up 1 node, 8 CPUs

Btw, the "x86" prefix would mean we want to either change pr_fmt() of arch/x86/kernel/smpboot.c (which I rather not) or not use pr_info (which I'd prefer).

Quoted 4 lines

Note the typographical details I added:

- I added an extra space after 'CPUs:' to make the table stand out better from far away

Ok.

Quoted 2 lines

- Removed the 'OK' - it really does not add any more information than the newline already does

Yes.

Quoted 2 lines

- Changed the 'Brought up' message to be more consistent with the prior messages.

Ok.

Quoted 3 lines

- Added nodes count to the 'Booted up' line. Since we count nodes and CPUs, we might as well want to demonstrate our superior counting skills and print out both.

Haha, ok.

Quoted 2 lines

- The 'node' counting uses the new num_digits() function - this was very easy to implement in my mockup ;-)

Ok.

Quoted 2 lines

- Note the singular spelling of 'node' in the 1-node case. Again this was easy in the mockup!

Should be easy to do :)

So how about the even shorter mockup above?

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#13 lore raw

Re: [PATCH 2/2] x86: Cleanup boot CPUs table

Quoted 33 lines · Borislav Petkov
Quoted 4 lines · Ingo Molnar

Could we, with another add-on patch, further compress the first half of the output as well?

Advanced output like this would be really cool:

Sure.

Quoted 9 lines
Quoted 9 lines
[    0.074509] x86: Booting node #0, CPUs:       #1  #2  #3  #4  #5  #6  #7
[    0.644008] x86: Booting node #1, CPUs:   #8  #9 #10 #11 #12 #13 #14 #15
[    1.245006] x86: Booting node #2, CPUs:  #16 #17 #18 #19 #20 #21 #22 #23
[    1.864005] x86: Booting node #3, CPUs:  #24 #25 #26 #27 #28 #29 #30 #31
[    2.489005] x86: Booting node #4, CPUs:  #32 #33 #34 #35 #36 #37 #38 #39
[    3.093005] x86: Booting node #5, CPUs:  #40 #41 #42 #43 #44 #45 #46 #47
[    3.698005] x86: Booting node #6, CPUs:  #48 #49 #50 #51 #52 #53 #54 #55
[    4.304005] x86: Booting node #7, CPUs:  #56 #57 #58 #59 #60 #61 #62 #63
[    4.961413] x86: Booted up 8 nodes, 64 CPUs

Boot(ing|ed) kinda wastes unnecessary space too, how about we go a step further:

[    0.074509] x86: Booting SMP configuration:
[    0.644008] .... node #0, CPUs:       #1  #2  #3  #4  #5  #6  #7
[    1.245006] .... node #1, CPUs:   #8  #9 #10 #11 #12 #13 #14 #15
[    1.864005] .... node #2, CPUs:  #16 #17 #18 #19 #20 #21 #22 #23
[    2.489005] .... node #3, CPUs:  #24 #25 #26 #27 #28 #29 #30 #31
[    3.093005] .... node #4, CPUs:  #32 #33 #34 #35 #36 #37 #38 #39
[    3.698005] .... node #5, CPUs:  #40 #41 #42 #43 #44 #45 #46 #47
[    4.304005] .... node #6, CPUs:  #48 #49 #50 #51 #52 #53 #54 #55
[    4.961413] .... node #7, CPUs:  #56 #57 #58 #59 #60 #61 #62 #63
[    5.245021] x86: Booted up 8 nodes, 64 CPUs
Quoted 3 lines
[    0.074509] x86: Booting SMP configuration:
[    0.072367] .... node #0, CPUs:     #1 #2 #3 #4 #5 #6 #7
[    0.686329] x86: Booted up 1 node, 8 CPUs

Nice!

Quoted 3 lines

Btw, the "x86" prefix would mean we want to either change pr_fmt() of arch/x86/kernel/smpboot.c (which I rather not) or not use pr_info (which I'd prefer).

Not using pr_info() for such specially formatted output is fine I think.

Thanks,

Ingo

maintainer
#14 lore raw

PATCH 1/1 x86, boot: Further compress CPUs bootup message

From: Borislav Petkov <[email protected]>

Turn it into:

[    0.066391] x86: Booting SMP configuration:
[    0.067008] .... node #  0, CPUs:        #1  #2  #3  #4  #5  #6  #7
[    0.595005] .... node #  1, CPUs:    #8  #9 #10 #11 #12 #13 #14 #15
[    1.193005] .... node #  2, CPUs:   #16 #17 #18 #19 #20 #21 #22 #23
[    1.789010] .... node #  3, CPUs:   #24 #25 #26 #27 #28 #29 #30 #31
[    2.395005] .... node #  4, CPUs:   #32 #33 #34 #35 #36 #37 #38 #39
[    2.996005] .... node #  5, CPUs:   #40 #41 #42 #43 #44 #45 #46 #47
[    3.594005] .... node #  6, CPUs:   #48 #49 #50 #51 #52 #53 #54 #55
[    4.209005] .... node #  7, CPUs:   #56 #57 #58 #59 #60 #61 #62 #63
[    4.819594] x86: Booted up 8 nodes, 64 CPUs

and

[    0.065309] x86: Booting SMP configuration:
[    0.066007] .... node #  0, CPUs:      #1 #2 #3 #4 #5 #6 #7
[    0.590281] x86: Booted up 1 node, 8 CPUs

and drop useless elements.

---
 arch/x86/kernel/smpboot.c | 17 +++++++++++++----
 kernel/smp.c              |  7 ++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)
arch/x86/kernel/smpboot.c +13 -4
index d41f3ba26ced..a383b285ad1d 100644
@@ -647,6 +647,14 @@ 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, %ld CPUs\n",
+	       num_nodes, (num_nodes > 1 ? "s" : ""), (long)num_online_cpus());
+}
+
 /* reduce the number of lines printed when booting a large cpu count system */
 static void announce_cpu(int cpu, int apicid)
 {
@@ -657,12 +665,15 @@ static void announce_cpu(int cpu, int apicid)
 	if (!width)
 		width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
 
+	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 #%3d, CPUs:  ", node);
 		}
 
 		/* Add padding for the BSP */
@@ -671,8 +682,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);
kernel/smp.c +6 -1
index 0564571dcdf7..685f11781cbc 100644
@@ -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 %ld CPUs\n", (long)num_online_cpus());
+}
+
 /* Called by boot processor to activate the rest. */
 void __init smp_init(void)
 {
@@ -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);
 }
 
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#15 lore raw

Re: [PATCH] x86, boot: Further compress CPUs bootup message

arch/x86/kernel/smpboot.c wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip) · line 656

Quoted 7 lines · Borislav Petkov
arch/x86/kernel/smpboot.c +7 -0
+void smp_announce(void)
+{
+	int num_nodes = num_online_nodes();
+
+	printk(KERN_INFO "x86: Booted up %d node%s, %ld CPUs\n",
+	       num_nodes, (num_nodes > 1 ? "s" : ""), (long)num_online_cpus());
+}

That (long) cast looks weird - num_online_cpus() is 'unsigned int' so changing the format to %d should do the trick, right?

kernel/smp.c void __init setup_nr_cpu_ids(void) · line 530

Quoted 4 lines
kernel/smp.c +4 -0
+void __weak smp_announce(void)
+{
+	printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
+}

Ditto.

Thanks,

Ingo

maintainer
#16 lore raw

PATCH 1/1 x86, boot: Further compress CPUs bootup message

From: Borislav Petkov <[email protected]>

Turn it into:

[    0.066391] x86: Booting SMP configuration:
[    0.067008] .... node #  0, CPUs:        #1  #2  #3  #4  #5  #6  #7
[    0.595005] .... node #  1, CPUs:    #8  #9 #10 #11 #12 #13 #14 #15
[    1.193005] .... node #  2, CPUs:   #16 #17 #18 #19 #20 #21 #22 #23
[    1.789010] .... node #  3, CPUs:   #24 #25 #26 #27 #28 #29 #30 #31
[    2.395005] .... node #  4, CPUs:   #32 #33 #34 #35 #36 #37 #38 #39
[    2.996005] .... node #  5, CPUs:   #40 #41 #42 #43 #44 #45 #46 #47
[    3.594005] .... node #  6, CPUs:   #48 #49 #50 #51 #52 #53 #54 #55
[    4.209005] .... node #  7, CPUs:   #56 #57 #58 #59 #60 #61 #62 #63
[    4.819594] x86: Booted up 8 nodes, 64 CPUs

and

[    0.065309] x86: Booting SMP configuration:
[    0.066007] .... node #  0, CPUs:      #1 #2 #3 #4 #5 #6 #7
[    0.590281] x86: Booted up 1 node, 8 CPUs

and drop useless elements.

---

-v1.1: Drop suspicious (long) cast.

 arch/x86/kernel/smpboot.c | 17 +++++++++++++----
 kernel/smp.c              |  7 ++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)
arch/x86/kernel/smpboot.c +13 -4
index d41f3ba26ced..5333b4c7e93c 100644
@@ -647,6 +647,14 @@ 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)
 {
@@ -657,12 +665,15 @@ static void announce_cpu(int cpu, int apicid)
 	if (!width)
 		width = num_digits(num_possible_cpus()) + 1; /* + '#' sign */
 
+	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 #%3d, CPUs:  ", node);
 		}
 
 		/* Add padding for the BSP */
@@ -671,8 +682,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);
kernel/smp.c +6 -1
index 0564571dcdf7..f5768b0c816a 100644
@@ -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)
 {
@@ -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);
 }
 
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#17 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

arch/x86/kernel/smpboot.c static void announce_cpu(int cpu, int apicid) · line 676

Quoted 2 lines · Borislav Petkov
arch/x86/kernel/smpboot.c +1 -1
-			pr_info("Booting Node %3d, Processors:", node);
+			printk(KERN_INFO ".... node #%3d, CPUs:  ", node);

I think this should use %*s# and num_digits(node) as well?

Thanks,

Ingo

maintainer
#18 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 7 lines · Ingo Molnar

Review

Quoted 2 lines · Borislav Petkov
(quoted diff) +1 -1
-			pr_info("Booting Node %3d, Processors:", node);
+			printk(KERN_INFO ".... node #%3d, CPUs:  ", node);

I think this should use %*s# and num_digits(node) as well?

How's that:

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

?

Btw, num_digits() needed to handle the val==0 case :)

---
From: Borislav Petkov <[email protected]>
Date: Sat, 28 Sep 2013 19:37:18 +0200
Subject: [PATCH -v1.2] x86, boot: Further compress CPUs bootup message

Turn it into (for example):

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

and drop useless elements.

---
 arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
 arch/x86/lib/misc.c       |  4 ++++
 kernel/smp.c              |  7 ++++++-
 3 files changed, 29 insertions(+), 6 deletions(-)
arch/x86/kernel/smpboot.c +19 -5
index d41f3ba26ced..2a165580fa16 100644
@@ -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 */
@@ -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);
arch/x86/lib/misc.c +4 -0
index bc35cde9769f..0325603c6fd5 100644
@@ -2,6 +2,10 @@ int num_digits(int val)
 {
 	int digits = 0;
 
+	/* Handle special case */
+	if (!val)
+		return 1;
+
 	while (val) {
 		val /= 10;
 		digits++;
kernel/smp.c +6 -1
index 0564571dcdf7..f5768b0c816a 100644
@@ -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)
 {
@@ -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);
 }
 
Signature · 10 lines
1.8.4



-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#19 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

arch/x86/lib/misc.c int num_digits(int val) · line 11

Quoted 11 lines · Borislav Petkov
arch/x86/lib/misc.c +4 -0
@@ -2,6 +2,10 @@ int num_digits(int val)
 {
 	int digits = 0;
 
+	/* Handle special case */
+	if (!val)
+		return 1;
+
 	while (val) {
 		val /= 10;
 		digits++;

Hm. I suspect this could then be written as:

int num_digits(int val)

{
	int digits = 0;

	do {
		val /= 10;
		digits++;
	} while (val);

	return digits;
}

No ugly special case! :-)

Thanks,

Ingo

maintainer
#20 lore raw

PATCH 1/1 x86, boot: Further compress CPUs bootup message

From: Borislav Petkov <[email protected]>

Turn it into (for example):

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

and drop useless elements.

While at it, change num_digits() to handle arg of 0 correctly, as Ingo suggested.

---
 arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
 arch/x86/lib/misc.c       |  4 ++--
 kernel/smp.c              |  7 ++++++-
 3 files changed, 27 insertions(+), 8 deletions(-)
arch/x86/kernel/smpboot.c +19 -5
index d41f3ba26ced..2a165580fa16 100644
@@ -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 */
@@ -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);
arch/x86/lib/misc.c +2 -2
index bc35cde9769f..903dfdc4dfd4 100644
@@ -2,10 +2,10 @@ int num_digits(int val)
 {
 	int digits = 0;
 
-	while (val) {
+	do {
 		val /= 10;
 		digits++;
-	}
+	} while (val);
 
 	return digits;
 }
kernel/smp.c +6 -1
index 0564571dcdf7..f5768b0c816a 100644
@@ -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)
 {
@@ -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);
 }
 
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#21 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

In reply to Ingo Molnar

How about:

m = 10;
d = 1;

while ( val >= m ) {
        m *= 10;
        d++;
}

... and not have a *divide* in there?

Man, entering code on a cell phone sucks...

Quoted 34 lines · Ingo Molnar

arch/x86/lib/misc.c int num_digits(int val) · line 11

Quoted 11 lines · Borislav Petkov
arch/x86/lib/misc.c +4 -0
@@ -2,6 +2,10 @@ int num_digits(int val)
 {
 	int digits = 0;
 
+	/* Handle special case */
+	if (!val)
+		return 1;
+
 	while (val) {
 		val /= 10;
 		digits++;

Hm. I suspect this could then be written as:

int num_digits(int val)

{
	int digits = 0;

	do {
		val /= 10;
		digits++;
	} while (val);

	return digits;
}

No ugly special case! :-)

Thanks,

Ingo

Signature · 1 line
Sent from my mobile phone.  Please pardon brevity and lack of formatting.
maintainer
#22 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 11 lines · H. Peter Anvin

How about:

m = 10;
d = 1;

while ( val >= m ) {
        m *= 10;
        d++;
}

... and not have a *divide* in there?

Yep, I know why :-)

And yes, that one works too.

Quoted 1 line

Man, entering code on a cell phone sucks...

Haha, that's why your variables are single letters :-)

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
maintainer
#23 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 1 line · Borislav Petkov

And yes, that one works too.

Btw, just to be thorough, we could handle negative numbers too:

int num_digits(int val)

{
        int m = 10;
        int d = 1;

        if (val < 0)
                val = -val;

        while (val >= m) {
                m *= 10;
                d++;
        }

        return d;
}
Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#24 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 6 lines · Borislav Petkov
Quoted 1 line · Borislav Petkov

And yes, that one works too.

Btw, just to be thorough, we could handle negative numbers too:

int num_digits(int val)

Quoted 14 lines
{
        int m = 10;
        int d = 1;

        if (val < 0)
                val = -val;

        while (val >= m) {
                m *= 10;
                d++;
        }

        return d;
}

I like the cell phone version better!

Thanks,

Ingo

maintainer
#25 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 21 lines · Ingo Molnar
Quoted 18 lines · Borislav Petkov
Quoted 1 line · Borislav Petkov

And yes, that one works too.

Btw, just to be thorough, we could handle negative numbers too:

int num_digits(int val)

{
        int m = 10;
        int d = 1;

        if (val < 0)
                val = -val;

        while (val >= m) {
                m *= 10;
                d++;
        }
Quoted 4 lines
Quoted 2 lines
        return d;
}

I like the cell phone version better!

This *is* the cell phone version + negative numbers handling.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#26 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

For negative numbers presumably we need to d++ for the minus sign, no?

Quoted 28 lines · Borislav Petkov
Quoted 21 lines · Ingo Molnar
Quoted 18 lines · Borislav Petkov
Quoted 1 line · Borislav Petkov

And yes, that one works too.

Btw, just to be thorough, we could handle negative numbers too:

int num_digits(int val)

{
        int m = 10;
        int d = 1;

        if (val < 0)
                val = -val;

        while (val >= m) {
                m *= 10;
                d++;
        }
Quoted 4 lines
Quoted 2 lines
        return d;
}

I like the cell phone version better!

This *is* the cell phone version + negative numbers handling.

Signature · 1 line
Sent from my mobile phone.  Please pardon brevity and lack of formatting.
maintainer
#27 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 1 line · H. Peter Anvin

For negative numbers presumably we need to d++ for the minus sign, no?

That's easy - the function is called num_digits, so we count only digits.

The real question is, is there a use case where we would need to count the sign too or only the digits?

And since I can't be clairvoyant, I'll leave it to future generations to decide what to do with the sign.

:-)

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
maintainer
#28 lore raw

PATCH 1/1 x86, boot: Further compress CPUs bootup message

From: Borislav Petkov <[email protected]>

Turn it into (for example):

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

---
 arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
 arch/x86/lib/misc.c       | 18 ++++++++++++------
 kernel/smp.c              |  7 ++++++-
 3 files changed, 37 insertions(+), 12 deletions(-)
arch/x86/kernel/smpboot.c +19 -5
index d41f3ba26ced..2a165580fa16 100644
@@ -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 */
@@ -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);
arch/x86/lib/misc.c +12 -6
index bc35cde9769f..9acca74a0833 100644
@@ -1,11 +1,17 @@
+/*
+ * Count only the digits in @val, without the sign
+ */
 int num_digits(int val)
 {
-	int digits = 0;
+	int m = 10;
+	int d = 1;
 
-	while (val) {
-		val /= 10;
-		digits++;
-	}
+	if (val < 0)
+		val = -val;
 
-	return digits;
+	while (val >= m) {
+		m *= 10;
+		d++;
+	}
+	return d;
 }
kernel/smp.c +6 -1
index 0564571dcdf7..f5768b0c816a 100644
@@ -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)
 {
@@ -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);
 }
 
Signature · 1 line
1.8.4
#29 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

In reply to Borislav Petkov

If the goal is to feed this to the field width in printf, which I would think would be the dominant use, then you do have to account for the minus sign.

Quoted 15 lines · Borislav Petkov
Quoted 1 line · H. Peter Anvin

For negative numbers presumably we need to d++ for the minus sign,

no?

That's easy - the function is called num_digits, so we count only digits.

The real question is, is there a use case where we would need to count the sign too or only the digits?

And since I can't be clairvoyant, I'll leave it to future generations to
decide what to do with the sign.

:-)

Signature · 1 line
Sent from my mobile phone.  Please pardon brevity and lack of formatting.
#30 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 3 lines · H. Peter Anvin

If the goal is to feed this to the field width in printf, which I would think would be the dominant use, then you do have to account for the minus sign.

The input here is always a nonzero positive integer.

Anyway, I have no objections against using the more generic library function either.

Thanks,

Ingo

maintainer
#31 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 10 lines · Ingo Molnar
Quoted 3 lines · H. Peter Anvin

If the goal is to feed this to the field width in printf, which I would think would be the dominant use, then you do have to account for the minus sign.

The input here is always a nonzero positive integer.

Anyway, I have no objections against using the more generic library function either.

Ok, let's do it this way - if someone wants to change it later, she can split/carve/write anew/whatever it... I don't care anymore.

:-)

--
From: Borislav Petkov <[email protected]>
Date: Sat, 28 Sep 2013 19:37:18 +0200
Subject: [PATCH] x86, boot: Further compress CPUs bootup message

Turn it into (for example):

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

---
 arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
 arch/x86/lib/misc.c       | 18 +++++++++++++-----
 kernel/smp.c              |  7 ++++++-
 3 files changed, 38 insertions(+), 11 deletions(-)
arch/x86/kernel/smpboot.c +19 -5
index d41f3ba26ced..2a165580fa16 100644
@@ -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 */
@@ -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);
arch/x86/lib/misc.c +13 -5
index bc35cde9769f..94f0c86ce7d0 100644
@@ -1,11 +1,19 @@
+/*
+ * Count the digits of @val including a possible sign.
+ */
 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;
 }
kernel/smp.c +6 -1
index 0564571dcdf7..f5768b0c816a 100644
@@ -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)
 {
@@ -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);
 }
 
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#32 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 9 lines · Borislav Petkov
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · H. Peter Anvin

If the goal is to feed this to the field width in printf, which I would think would be the dominant use, then you do have to account for the minus sign.

The input here is always a nonzero positive integer.

Quoted 7 lines
Quoted 2 lines

Anyway, I have no objections against using the more generic library function either.

Ok, let's do it this way - if someone wants to change it later, she can split/carve/write anew/whatever it... I don't care anymore.

:-)

Looks perfect to me!

Thanks,

Ingo

#33 lore raw

[tip:x86/boot] x86/boot: Further compress CPUs bootup message

In reply to Borislav Petkov
x86/boot: Further compress CPUs bootup message
Commit-ID:  a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Gitweb:     http://git.kernel.org/tip/a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 30 Sep 2013 11:56:24 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 1 Oct 2013 10:52:30 +0200

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

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

---
 arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
 arch/x86/lib/misc.c       | 20 +++++++++++++++-----
 kernel/smp.c              |  7 ++++++-
 3 files changed, 40 insertions(+), 11 deletions(-)
arch/x86/kernel/smpboot.c +19 -5
index d41f3ba..2a16558 100644
@@ -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 */
@@ -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);
arch/x86/lib/misc.c +15 -5
index bc35cde..76b373a 100644
@@ -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;
 }
kernel/smp.c +6 -1
index 0564571..f5768b0 100644
@@ -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)
 {
@@ -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);
 }
 
#34 lore raw

Re: [tip:x86/boot] x86/boot: Further compress CPUs bootup message

Quoted 21 lines · tip-bot for Borislav Petkov
Commit-ID:  a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Gitweb:     http://git.kernel.org/tip/a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 30 Sep 2013 11:56:24 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 1 Oct 2013 10:52:30 +0200

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

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

Bah, ugly..

#35 lore raw

Re: [tip:x86/boot] x86/boot: Further compress CPUs bootup message

Quoted 32 lines · Peter Zijlstra
Quoted 21 lines · tip-bot for Borislav Petkov
Commit-ID:  a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Gitweb:     http://git.kernel.org/tip/a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 30 Sep 2013 11:56:24 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 1 Oct 2013 10:52:30 +0200

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

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

That's not how it looks like here:

[    0.369572] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
[    0.377957] x86: Booting SMP configuration:
[    0.382294] .... node  #0, CPUs:        #1  #2  #3
[    0.428340] .... node  #1, CPUs:    #4  #5  #6  #7
[    0.564304] .... node  #2, CPUs:    #8  #9 #10 #11
[    0.700242] .... node  #3, CPUs:   #12 #13 #14 #15
[    0.836819] x86: Booted up 4 nodes, 16 CPUs
[    0.841487] smpboot: Total of 16 processors activated (73944.72 BogoMIPS)

and:

[    0.304732] x86: Booting SMP configuration:
[    0.326682] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
[    0.309034] .... node  #0, CPUs:        #1  #2  #3  #4  #5  #6  #7
[    0.417810] .... node  #1, CPUs:    #8  #9 #10 #11 #12 #13 #14 #15
[    0.608563] x86: Booted up 2 nodes, 16 CPUs
[    0.613169] smpboot: Total of 16 processors activated (89598.99 BogoMIPS)

Thanks,

Ingo

#36 lore raw

Re: [tip:x86/boot] x86/boot: Further compress CPUs bootup message

In reply to Peter Zijlstra
Quoted 32 lines · Peter Zijlstra
Quoted 21 lines · tip-bot for Borislav Petkov
Commit-ID:  a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Gitweb:     http://git.kernel.org/tip/a17bce4d1dce8f3cf714bc2e5d8e4bac009dc077
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 30 Sep 2013 11:56:24 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 1 Oct 2013 10:52:30 +0200

x86/boot: Further compress CPUs bootup message

Turn it into (for example):

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

operator error here.. this was from the (old) fallback kernel; the new one didn't actually boot.

maintainer
#37 lore raw

Re: [tip:x86/boot] x86/boot: Further compress CPUs bootup message

Quoted 9 lines · Peter Zijlstra
Quoted 6 lines
[    0.314494] smpboot: Booting Node   0, Processors  #   1[    0.333365] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
 #   2 #   3 #   4 #   5 OK
[    0.398473] smpboot: Booting Node   1, Processors  #   6 #   7 #   8 #   9 #  10 #  11 OK
[    0.565198] smpboot: Booting Node   0, Processors  #  12 #  13 #  14 #  15 #  16 #  17 OK
[    0.654558] smpboot: Booting Node   1, Processors  #  18 #  19 #  20 #  21 #  22 #  23 OK
[    0.743527] Brought up 24 CPUs

operator error here.. this was from the (old) fallback kernel; the new one didn't actually boot.

FWIW, this will happen, regardless of what we do:

[    0.089350] x86: Booting SMP configuration:
[    0.104355] NMI watchdog: enabled on all CPUs, permanently consumes one hw-PMU counter.
[    0.089427] .... node  #0, CPUs:      #1 #2 #3
[    0.136301] x86: Booted up 1 node, 4 CPUs
[    0.136442] smpboot: Total of 4 processors activated (23146.32 BogoMIPS)

as the NMI watchdog thing keeps shouting in-between. Do we still need it
- I mean, how can I really use the info that NMI watchdog is consuming a perf counter? I mean I know how, but do people actually use that info or everyone knows already? :-)

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#38 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

In reply to H. Peter Anvin
Quoted 11 lines · H. Peter Anvin

How about:

m = 10;
d = 1;

while ( val >= m ) {
        m *= 10;
        d++;
}

... and not have a *divide* in there?

Yeah :-)

Quoted 1 line

Man, entering code on a cell phone sucks...

Indeed that explains the BASIC style! (and you got the 8-space tabs right on a html mailer - wow, that's impressive.)

It's also probably the first time that code entered on an ordinary cell phone has gets into the Linux kernel, so it's probably a new Linux milestone, in a twisted, sick way. ;-)

Thanks,

Ingo

maintainer
#39 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 3 lines · Ingo Molnar

It's also probably the first time that code entered on an ordinary cell phone has gets into the Linux kernel, so it's probably a new Linux milestone, in a twisted, sick way. ;-)

We could put the following comment *below* the function in arch/x86/lib/misc.c:

/*
* Sent from my mobile phone. Please pardon brevity and lack of formatting. */

LoooL.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#40 lore raw

Re: [PATCH -v1.1] x86, boot: Further compress CPUs bootup message

Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Ingo Molnar

It's also probably the first time that code entered on an ordinary cell phone has gets into the Linux kernel, so it's probably a new Linux milestone, in a twisted, sick way. ;-)

Quoted 9 lines

We could put the following comment *below* the function in arch/x86/lib/misc.c:

/*
* Sent from my mobile phone. Please pardon brevity and lack of formatting. */

LoooL.

*Snork* ;)

-hpa

#41 lore raw

Re: [PATCH 2/2] x86: Cleanup boot CPUs table

In reply to Ingo Molnar
Quoted 2 lines · Ingo Molnar
Quoted 2 lines
[    0.072367] x86: Booting node #0, CPUs:     #1 #2 #3 #4 #5 #6 #7 <-- 
[    0.686329] x86: Booted up 1 node, 8 CPUs
                                          ^ 
Quoted 3 lines

- Added nodes count to the 'Booted up' line. Since we count nodes and CPUs, we might as well want to demonstrate our superior counting skills and print out both.

What superior counting skills? ;-)

#42 lore raw

[tip:x86/boot] x86: Improve the printout of the SMP bootup CPU table

In reply to Borislav Petkov
x86: Improve the printout of the SMP bootup CPU table
Commit-ID:  646e29a1789a3a936871008c15199c50367bf291
Gitweb:     http://git.kernel.org/tip/646e29a1789a3a936871008c15199c50367bf291
Author:     Borislav Petkov <[email protected]>
AuthorDate: Fri, 27 Sep 2013 16:35:54 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 28 Sep 2013 10:10:26 +0200

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 #17 #18 #19 #20 #21 #22 #23 OK
 [    1.864005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 #30 #31 OK
 [    2.489005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 #38 #39 OK
 [    3.093005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 #46 #47 OK
 [    3.698005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 #54 #55 OK
 [    4.304005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 #62 #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
---
 arch/x86/include/asm/misc.h |  6 ++++++
 arch/x86/kernel/smpboot.c   | 21 +++++++++++++++------
 arch/x86/lib/Makefile       |  2 +-
 arch/x86/lib/misc.c         | 11 +++++++++++
 4 files changed, 33 insertions(+), 7 deletions(-)
arch/x86/include/asm/misc.h new file +6 -0
new file mode 100644
index 0000000..475f5bb
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
arch/x86/kernel/smpboot.c +15 -6
index 6cacab6..d41f3ba 100644
@@ -73,11 +73,10 @@
 #include <asm/setup.h>
 #include <asm/uv/uv.h>
 #include <linux/mc146818rtc.h>
-
 #include <asm/smpboot_hooks.h>
 #include <asm/i8259.h>
-
 #include <asm/realmode.h>
+#include <asm/misc.h>
 
 /* 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);
arch/x86/lib/Makefile +1 -1
index 96b2c66..992d63b 100644
@@ -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
arch/x86/lib/misc.c new file +11 -0
new file mode 100644
index 0000000..bc35cde
@@ -0,0 +1,11 @@
+int num_digits(int val)
+{
+	int digits = 0;
+
+	while (val) {
+		val /= 10;
+		digits++;
+	}
+
+	return digits;
+}
#43 lore raw

Re: [tip:x86/boot] x86: Improve the printout of the SMP bootup CPU table

Quoted 90 lines · tip-bot for Borislav Petkov
Commit-ID:  646e29a1789a3a936871008c15199c50367bf291
Gitweb:     http://git.kernel.org/tip/646e29a1789a3a936871008c15199c50367bf291
Author:     Borislav Petkov <[email protected]>
AuthorDate: Fri, 27 Sep 2013 16:35:54 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 28 Sep 2013 10:10:26 +0200

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 #17 #18 #19 #20 #21 #22 #23 OK
 [    1.864005] smpboot: Booting Node   3, Processors: #24 #25 #26 #27 #28 #29 #30 #31 OK
 [    2.489005] smpboot: Booting Node   4, Processors: #32 #33 #34 #35 #36 #37 #38 #39 OK
 [    3.093005] smpboot: Booting Node   5, Processors: #40 #41 #42 #43 #44 #45 #46 #47 OK
 [    3.698005] smpboot: Booting Node   6, Processors: #48 #49 #50 #51 #52 #53 #54 #55 OK
 [    4.304005] smpboot: Booting Node   7, Processors: #56 #57 #58 #59 #60 #61 #62 #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
---
 arch/x86/include/asm/misc.h |  6 ++++++
 arch/x86/kernel/smpboot.c   | 21 +++++++++++++++------
 arch/x86/lib/Makefile       |  2 +-
 arch/x86/lib/misc.c         | 11 +++++++++++
 4 files changed, 33 insertions(+), 7 deletions(-)
arch/x86/include/asm/misc.h new file +6 -0
new file mode 100644
index 0000000..475f5bb
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
arch/x86/kernel/smpboot.c +5 -3
index 6cacab6..d41f3ba 100644
@@ -73,11 +73,10 @@
 #include <asm/setup.h>
 #include <asm/uv/uv.h>
 #include <linux/mc146818rtc.h>
-
 #include <asm/smpboot_hooks.h>
 #include <asm/i8259.h>
-
 #include <asm/realmode.h>
+#include <asm/misc.h>
 
 /* 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");

arch/x86/kernel/smpboot.c static void announce_cpu(int cpu, int apicid) · line 670

Quoted 10 lines
arch/x86/kernel/smpboot.c +5 -3
                        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, " ");

what's point to add the pad?

How do you know BIOS MADT or kernel MADT parsing code would have cpu1 the same node cpu0?

Yinghai

maintainer
#44 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

In reply to Ingo Molnar
Quoted 5 lines · Ingo Molnar

That message was cool and interesting back in the days when we wrote lockdep ('hey, look ma, it really works!!'), but there hasn't been any breakage in that area for a long time and it definitely does not deserve one line of log spam per CPU! Especially if it messes up such a nice CPU bootup table.

Right. The comment in alternatives_enable_smp() talks about older binutils and could be a useful info if we encounter the issue again. Should I keep it or are we talking really old, i.e.

obsolete-we-will-never-use-them-anywhere-and-if-someone-does-we-dont-care

binutils?

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#45 lore raw

Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly

Quoted 7 lines · Borislav Petkov
Quoted 5 lines · Ingo Molnar

That message was cool and interesting back in the days when we wrote lockdep ('hey, look ma, it really works!!'), but there hasn't been any breakage in that area for a long time and it definitely does not deserve one line of log spam per CPU! Especially if it messes up such a nice CPU bootup table.

Quoted 7 lines

Right. The comment in alternatives_enable_smp() talks about older binutils and could be a useful info if we encounter the issue again. Should I keep it or are we talking really old, i.e.

obsolete-we-will-never-use-them-anywhere-and-if-someone-does-we-dont-care

binutils?

See this commit from ~5 years ago:

17abecfe651c x86: fix up alternatives with lockdep enabled

I was thinking about removing the message back then. Nobody ever
complained: code patching is so fundamental to a properly functioning Linux kernel that broken binutils would stick out like a sore thumb - and not just related to lockdep.

So lets remove it.

Thanks,

Ingo