From: Ingo Molnar <mingo@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: hpa@zytor.com, linux-kernel@vger.kernel.org,
huawei.libin@huawei.com, wangyijing@huawei.com,
fenghua.yu@intel.com, tglx@linutronix.de, guohanjun@huawei.com,
paul.gortmaker@windriver.com, linux-tip-commits@vger.kernel.org
Subject: Re: [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly
Date: Fri, 27 Sep 2013 08:51:15 +0200 [thread overview]
Message-ID: <20130927065115.GA6852@gmail.com> (raw)
In-Reply-To: <20130926231545.GD10123@pd.tnic>
* Borislav Petkov <bp@alien8.de> 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
next prev parent reply other threads:[~2013-09-27 6:51 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 10:57 [PATCH] x86, smpboot: fix announce_cpu() to print the last OK Libin
2013-09-05 17:52 ` [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly tip-bot for Libin
2013-09-25 10:07 ` Borislav Petkov
2013-09-25 18:29 ` Ingo Molnar
2013-09-26 23:15 ` Borislav Petkov
2013-09-27 6:51 ` Ingo Molnar [this message]
2013-09-27 10:38 ` Borislav Petkov
2013-09-27 14:32 ` Borislav Petkov
2013-09-27 14:34 ` [PATCH 1/2] x86, alternatives: Drop ancient lockdep fixup message Borislav Petkov
2013-09-28 8:28 ` [tip:core/locking] lockdep, x86/alternatives: " tip-bot for Borislav Petkov
2013-09-27 14:35 ` [PATCH 2/2] x86: Cleanup boot CPUs table Borislav Petkov
2013-09-28 8:25 ` Ingo Molnar
2013-09-28 10:23 ` Borislav Petkov
2013-09-28 13:44 ` Ingo Molnar
2013-09-28 17:47 ` [PATCH] x86, boot: Further compress CPUs bootup message Borislav Petkov
2013-09-28 17:54 ` Ingo Molnar
2013-09-28 18:04 ` [PATCH -v1.1] " Borislav Petkov
2013-09-28 18:12 ` Ingo Molnar
2013-09-28 19:15 ` Borislav Petkov
2013-09-28 19:25 ` Ingo Molnar
2013-09-28 19:36 ` [PATCH -v1.3] " Borislav Petkov
2013-09-28 19:42 ` [PATCH -v1.1] " H. Peter Anvin
2013-09-28 19:49 ` Borislav Petkov
2013-09-28 19:54 ` Borislav Petkov
2013-09-28 19:58 ` Ingo Molnar
2013-09-28 20:08 ` Borislav Petkov
2013-09-28 23:13 ` H. Peter Anvin
2013-09-29 9:14 ` Borislav Petkov
2013-09-29 15:17 ` [PATCH -v1.4] " Borislav Petkov
2013-09-29 15:44 ` [PATCH -v1.1] " H. Peter Anvin
2013-09-30 6:28 ` Ingo Molnar
2013-09-30 9:56 ` Borislav Petkov
2013-10-01 8:53 ` Ingo Molnar
2013-10-01 9:10 ` [tip:x86/boot] x86/boot: " tip-bot for Borislav Petkov
2013-10-02 11:52 ` Peter Zijlstra
2013-10-02 12:18 ` Ingo Molnar
2013-10-02 12:20 ` Peter Zijlstra
2013-10-02 13:55 ` Borislav Petkov
2013-09-28 19:58 ` [PATCH -v1.1] x86, boot: " Ingo Molnar
2013-09-28 20:10 ` Borislav Petkov
2013-09-29 5:10 ` H. Peter Anvin
2013-09-29 2:55 ` [PATCH 2/2] x86: Cleanup boot CPUs table Mike Galbraith
2013-09-28 8:28 ` [tip:x86/boot] x86: Improve the printout of the SMP bootup CPU table tip-bot for Borislav Petkov
2013-09-29 4:25 ` Yinghai Lu
2013-09-27 12:48 ` [tip:x86/urgent] x86/smpboot: Fix announce_cpu() to printk() the last "OK" properly Borislav Petkov
2013-09-27 13:33 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130927065115.GA6852@gmail.com \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=guohanjun@huawei.com \
--cc=hpa@zytor.com \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=tglx@linutronix.de \
--cc=wangyijing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).