2013-09-05 11:01:03

by Li Bin

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Libin <[email protected]>
---
arch/x86/kernel/smpboot.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index aecc98a..549b8cb 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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",
--
1.8.2.1


Subject: [tip:x86/urgent] 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.

Signed-off-by: Libin <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
[ tweaked the changelog, removed unnecessary line break, tweaked the format to align the fields vertically. ]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/smpboot.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index aecc98a..6cacab6 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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",

2013-09-25 18:18:23

by Borislav Petkov

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

On Thu, Sep 05, 2013 at 10:52:15AM -0700, tip-bot for Libin wrote:
> 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.
>
> Signed-off-by: Libin <[email protected]>
> Cc: <[email protected]>
> Cc: <[email protected]>
> Cc: <[email protected]>
> Cc: <[email protected]>
> Link: http://lkml.kernel.org/r/[email protected]
> [ tweaked the changelog, removed unnecessary line break, tweaked the format to align the fields vertically. ]
> Signed-off-by: Ingo Molnar <[email protected]>

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.

2013-09-25 18:29:41

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> On Thu, Sep 05, 2013 at 10:52:15AM -0700, tip-bot for Libin wrote:
> > 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.
> >
> > Signed-off-by: Libin <[email protected]>
> > Cc: <[email protected]>
> > Cc: <[email protected]>
> > Cc: <[email protected]>
> > Cc: <[email protected]>
> > Link: http://lkml.kernel.org/r/[email protected]
> > [ tweaked the changelog, removed unnecessary line break, tweaked the format to align the fields vertically. ]
> > Signed-off-by: Ingo Molnar <[email protected]>
>
> 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)

Indeed, that should be fixed.

Thanks,

Ingo

2013-09-26 23:16:03

by Borislav Petkov

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

On Wed, Sep 25, 2013 at 08:29:36PM +0200, Ingo Molnar wrote:
> 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:

--
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6cacab671f9b..1cf5957b1035 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-27 06:51:21

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> On Wed, Sep 25, 2013 at 08:29:36PM +0200, Ingo Molnar wrote:
> > 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
>
> ?

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? :-)

> 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.

> 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:

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

2013-09-27 10:38:13

by Borislav Petkov

[permalink] [raw]
Subject: 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>

> (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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-27 12:48:53

by Borislav Petkov

[permalink] [raw]
Subject: 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:
> 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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-27 13:33:09

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> On Fri, Sep 27, 2013 at 08:51:15AM +0200, Ingo Molnar wrote:
> > 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?

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

2013-09-27 14:32:57

by Borislav Petkov

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

On Fri, Sep 27, 2013 at 12:38:02PM +0200, Borislav Petkov wrote:
> On Fri, Sep 27, 2013 at 08:51:15AM +0200, Ingo Molnar wrote:
>
> <snip stuff to do>
>
> > (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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-27 14:34:48

by Borislav Petkov

[permalink] [raw]
Subject: [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

Cc: Ingo Molnar <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/alternative.c | 11 -----------
1 file changed, 11 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 15e8563e5c24..df94598ad05a 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -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);

--
1.8.4

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-27 14:35:59

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH 2/2] x86: Cleanup boot CPUs table

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

Cc: Ingo Molnar <[email protected]>
Cc: Libin <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Borislav Petkov <[email protected]>
---
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

diff --git a/arch/x86/include/asm/misc.h b/arch/x86/include/asm/misc.h
new file mode 100644
index 000000000000..475f5bbc7f53
--- /dev/null
+++ b/arch/x86/include/asm/misc.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6cacab671f9b..d41f3ba26ced 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 96b2c6697c9d..992d63bb154f 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -16,7 +16,7 @@ clean-files := inat-tables.c

obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o

-lib-y := delay.o
+lib-y := delay.o misc.o
lib-y += thunk_$(BITS).o
lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
lib-y += memcpy_$(BITS).o
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
new file mode 100644
index 000000000000..bc35cde9769f
--- /dev/null
+++ b/arch/x86/lib/misc.c
@@ -0,0 +1,11 @@
+int num_digits(int val)
+{
+ int digits = 0;
+
+ while (val) {
+ val /= 10;
+ digits++;
+ }
+
+ return digits;
+}
--
1.8.4

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 08:25:49

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> 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

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:

> [ 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:

> [ 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

Subject: [tip:core/locking] 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

Signed-off-by: Borislav Petkov <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/alternative.c | 11 -----------
1 file changed, 11 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 15e8563..df94598 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -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);

Subject: [tip:x86/boot] 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

Signed-off-by: Borislav Petkov <[email protected]>
Cc: Libin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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(-)

diff --git a/arch/x86/include/asm/misc.h b/arch/x86/include/asm/misc.h
new file mode 100644
index 0000000..475f5bb
--- /dev/null
+++ b/arch/x86/include/asm/misc.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_X86_MISC_H
+#define _ASM_X86_MISC_H
+
+int num_digits(int val);
+
+#endif /* _ASM_X86_MISC_H */
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6cacab6..d41f3ba 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 96b2c66..992d63b 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -16,7 +16,7 @@ clean-files := inat-tables.c

obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o

-lib-y := delay.o
+lib-y := delay.o misc.o
lib-y += thunk_$(BITS).o
lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o
lib-y += memcpy_$(BITS).o
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
new file mode 100644
index 0000000..bc35cde
--- /dev/null
+++ b/arch/x86/lib/misc.c
@@ -0,0 +1,11 @@
+int num_digits(int val)
+{
+ int digits = 0;
+
+ while (val) {
+ val /= 10;
+ digits++;
+ }
+
+ return digits;
+}

2013-09-28 10:23:15

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 10:25:42AM +0200, Ingo Molnar wrote:
> 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.

> > [ 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

> > [ 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).

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

Ok.

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

Yes.

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

Ok.

> - 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.

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

Ok.

> - 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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 13:44:57

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> On Sat, Sep 28, 2013 at 10:25:42AM +0200, Ingo Molnar wrote:
> > 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.
>
> > > [ 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
>
>
> [ 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!

> 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

2013-09-28 17:48:00

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/smpboot.c | 17 +++++++++++++----
kernel/smp.c | 7 ++++++-
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba26ced..a383b285ad1d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571dcdf7..685f11781cbc 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

--
1.8.4

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 17:54:53

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

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

> +void __weak smp_announce(void)
> +{
> + printk(KERN_INFO "Brought up %ld CPUs\n", (long)num_online_cpus());
> +}

Ditto.

Thanks,

Ingo

2013-09-28 18:05:09

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH -v1.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.

Signed-off-by: Borislav Petkov <[email protected]>
---

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


arch/x86/kernel/smpboot.c | 17 +++++++++++++----
kernel/smp.c | 7 ++++++-
2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba26ced..5333b4c7e93c 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571dcdf7..f5768b0c816a 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

--
1.8.4

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 18:12:43

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

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

2013-09-28 19:15:16

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 08:12:36PM +0200, Ingo Molnar wrote:
>
> * Borislav Petkov <[email protected]> wrote:
>
> > - 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.

Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
arch/x86/lib/misc.c | 4 ++++
kernel/smp.c | 7 ++++++-
3 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba26ced..2a165580fa16 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde9769f..0325603c6fd5 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -2,6 +2,10 @@ int num_digits(int val)
{
int digits = 0;

+ /* Handle special case */
+ if (!val)
+ return 1;
+
while (val) {
val /= 10;
digits++;
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571dcdf7..f5768b0c816a 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

--
1.8.4



--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 19:25:52

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> @@ -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

2013-09-28 19:36:36

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH -v1.3] 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.

Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
arch/x86/lib/misc.c | 4 ++--
kernel/smp.c | 7 ++++++-
3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba26ced..2a165580fa16 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde9769f..903dfdc4dfd4 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -2,10 +2,10 @@ int num_digits(int val)
{
int digits = 0;

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

return digits;
}
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571dcdf7..f5768b0c816a 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

--
1.8.4

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 19:43:17

by H. Peter Anvin

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

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...


Ingo Molnar <[email protected]> wrote:
>
>* Borislav Petkov <[email protected]> wrote:
>
>> @@ -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

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

2013-09-28 19:49:36

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 12:42:37PM -0700, H. Peter Anvin wrote:
> 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.

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

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

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 19:54:56

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 09:49:27PM +0200, Borislav Petkov wrote:
> 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;
}

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 19:58:11

by Ingo Molnar

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


* H. Peter Anvin <[email protected]> wrote:

> How about:
>
> m = 10;
> d = 1;
>
> while ( val >= m ) {
> m *= 10;
> d++;
> }
>
> ... and not have a *divide* in there?

Yeah :-)

> 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

2013-09-28 19:58:40

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> On Sat, Sep 28, 2013 at 09:49:27PM +0200, Borislav Petkov wrote:
> > 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;
> }

I like the cell phone version better!

Thanks,

Ingo

2013-09-28 20:08:45

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 09:58:33PM +0200, Ingo Molnar wrote:
>
> * Borislav Petkov <[email protected]> wrote:
>
> > On Sat, Sep 28, 2013 at 09:49:27PM +0200, Borislav Petkov wrote:
> > > 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;
> > }
>
> I like the cell phone version better!

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

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 20:11:00

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 09:58:04PM +0200, Ingo Molnar wrote:
> 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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-28 23:14:25

by H. Peter Anvin

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

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

Borislav Petkov <[email protected]> wrote:
>On Sat, Sep 28, 2013 at 09:58:33PM +0200, Ingo Molnar wrote:
>>
>> * Borislav Petkov <[email protected]> wrote:
>>
>> > On Sat, Sep 28, 2013 at 09:49:27PM +0200, Borislav Petkov wrote:
>> > > 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;
>> > }
>>
>> I like the cell phone version better!
>
>This *is* the cell phone version + negative numbers handling.

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

2013-09-29 02:57:18

by Mike Galbraith

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

On Sat, 2013-09-28 at 10:25 +0200, Ingo Molnar wrote:

> > [ 0.072367] x86: Booting node #0, CPUs: #1 #2 #3 #4 #5 #6 #7 <--
> > [ 0.686329] x86: Booted up 1 node, 8 CPUs
^
> - 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? ;-)

2013-09-29 04:25:27

by Yinghai Lu

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

On Sat, Sep 28, 2013 at 1:28 AM, tip-bot for Borislav Petkov
<[email protected]> wrote:
> 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
>
> Signed-off-by: Borislav Petkov <[email protected]>
> Cc: Libin <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Link: http://lkml.kernel.org/r/[email protected]
> Signed-off-by: Ingo Molnar <[email protected]>
> ---
> 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(-)
>
> diff --git a/arch/x86/include/asm/misc.h b/arch/x86/include/asm/misc.h
> new file mode 100644
> index 0000000..475f5bb
> --- /dev/null
> +++ b/arch/x86/include/asm/misc.h
> @@ -0,0 +1,6 @@
> +#ifndef _ASM_X86_MISC_H
> +#define _ASM_X86_MISC_H
> +
> +int num_digits(int val);
> +
> +#endif /* _ASM_X86_MISC_H */
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 6cacab6..d41f3ba 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -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, " ");

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

2013-09-29 05:11:54

by H. Peter Anvin

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

On 09/28/2013 01:10 PM, Borislav Petkov wrote:
> On Sat, Sep 28, 2013 at 09:58:04PM +0200, Ingo Molnar wrote:
>> 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.
>

*Snork* ;)

-hpa

2013-09-29 09:15:03

by Borislav Petkov

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

On Sat, Sep 28, 2013 at 04:13:29PM -0700, H. Peter Anvin wrote:
> 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.

:-)

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-09-29 15:17:52

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH -v1.4] 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.

Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
arch/x86/lib/misc.c | 18 ++++++++++++------
kernel/smp.c | 7 ++++++-
3 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba26ced..2a165580fa16 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde9769f..9acca74a0833 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -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;
}
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571dcdf7..f5768b0c816a 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

--
1.8.4

2013-09-29 15:45:46

by H. Peter Anvin

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

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.

Borislav Petkov <[email protected]> wrote:
>On Sat, Sep 28, 2013 at 04:13:29PM -0700, H. Peter Anvin wrote:
>> 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.
>
>:-)

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

2013-09-30 06:28:53

by Ingo Molnar

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


* H. Peter Anvin <[email protected]> wrote:

> 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

2013-09-30 09:56:36

by Borislav Petkov

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

On Mon, Sep 30, 2013 at 08:28:48AM +0200, Ingo Molnar wrote:
> * H. Peter Anvin <[email protected]> wrote:
>
> > 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.

Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
arch/x86/lib/misc.c | 18 +++++++++++++-----
kernel/smp.c | 7 ++++++-
3 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba26ced..2a165580fa16 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde9769f..94f0c86ce7d0 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -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;
}
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571dcdf7..f5768b0c816a 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

--
1.8.4

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

2013-10-01 08:53:17

by Ingo Molnar

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


* Borislav Petkov <[email protected]> wrote:

> On Mon, Sep 30, 2013 at 08:28:48AM +0200, Ingo Molnar wrote:
> > * H. Peter Anvin <[email protected]> wrote:
> >
> > > 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.
>
> :-)

Looks perfect to me!

Thanks,

Ingo

Subject: [tip:x86/boot] 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.

Signed-off-by: Borislav Petkov <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Linus Torvalds <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/smpboot.c | 24 +++++++++++++++++++-----
arch/x86/lib/misc.c | 20 +++++++++++++++-----
kernel/smp.c | 7 ++++++-
3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index d41f3ba..2a16558 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -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);
diff --git a/arch/x86/lib/misc.c b/arch/x86/lib/misc.c
index bc35cde..76b373a 100644
--- a/arch/x86/lib/misc.c
+++ b/arch/x86/lib/misc.c
@@ -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;
}
diff --git a/kernel/smp.c b/kernel/smp.c
index 0564571..f5768b0 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -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);
}

2013-10-02 11:53:04

by Peter Zijlstra

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

On Tue, Oct 01, 2013 at 02:10:30AM -0700, tip-bot for Borislav Petkov wrote:
> 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
>

[ 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..

2013-10-02 12:18:42

by Ingo Molnar

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


* Peter Zijlstra <[email protected]> wrote:

> On Tue, Oct 01, 2013 at 02:10:30AM -0700, tip-bot for Borislav Petkov wrote:
> > 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
> >
>
> [ 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

2013-10-02 12:20:41

by Peter Zijlstra

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

On Wed, Oct 02, 2013 at 01:52:35PM +0200, Peter Zijlstra wrote:
> On Tue, Oct 01, 2013 at 02:10:30AM -0700, tip-bot for Borislav Petkov wrote:
> > 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
> >
>
> [ 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.

2013-10-02 13:55:34

by Borislav Petkov

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

On Wed, Oct 02, 2013 at 02:20:20PM +0200, Peter Zijlstra wrote:
> > [ 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.

--
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--