From: Ingo Molnar <mingo@elte.hu>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org, Milton Miller <miltonm@bga.com>,
Andrew Morton <akpm@linux-foundation.org>,
arjanvandeven@gmail.com,
Linus Torvalds <torvalds@linux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: smp: Start up non-boot CPUs asynchronously
Date: Tue, 31 Jan 2012 13:52:32 +0100 [thread overview]
Message-ID: <20120131125232.GD4408@elte.hu> (raw)
In-Reply-To: <20120130205444.22f5e26a@infradead.org>
* Arjan van de Ven <arjan@infradead.org> wrote:
> >From 3700e391ab2841a9f9241e4e31a6281aa59be5f1 Mon Sep 17 00:00:00 2001
> From: Arjan van de Ven <arjan@linux.intel.com>
> Date: Mon, 30 Jan 2012 20:44:51 -0800
> Subject: [PATCH] smp: Start up non-boot CPUs asynchronously
>
> The starting of the "not first" CPUs actually takes a lot of
> boot time of the kernel... upto "minutes" on some of the
> bigger SGI boxes. Right now, this is a fully sequential
> operation with the rest of the kernel boot.
Yeah.
> This patch turns this bringup of the other cpus into an
> asynchronous operation, saving significant kernel boot time
> (40% on my laptop!!). Basically now CPUs get brought up in
> parallel to disk enumeration, graphic mode bringup etc etc
> etc.
Very nice!
> Note that the implementation in this patch still waits for all
> CPUs to be brought up before starting userspace; I would love
> to remove that restriction over time (technically that is
> simple), but that becomes then a change in behavior... I'd
> like to see more discussion on that being a good idea before I
> write that patch.
Yeah, it's a good idea to be conservative with that - most of
the silent assumptions will be on the kernel init side anyway
and we want to map those out first, without any userspace
variance mixed in.
I'd expect this patch to eventually break stuff in the kernel -
we'll fix any kernel bugs that get uncovered, and we can move on
to make things more parallel once that process has stabilized.
> Second note: We add a small delay between the bring up of
> cpus, this is needed to actually get a boot time improvement.
> If we bring up CPUs straight back-to-back, we hog the cpu
> hotplug lock for write, and that lock is used everywhere
> during initialization for read. By adding a small delay, we
> allow those tasks to make progress.
> +void __init async_cpu_up(void *data, async_cookie_t cookie)
> +{
> + unsigned long nr = (unsigned long) data;
> + /*
> + * we can only up one cpu at a time, due to the hotplug lock;
> + * it's better to wait for all earlier CPUs to be done before
> + * us so that the bring up order is predictable.
> + */
> + async_synchronize_cookie(cookie);
> + /*
> + * wait a little bit of time between cpus, to allow
> + * the kernel boot to not get stuck for a long time
> + * on the hotplug lock. We wait longer for the first
> + * CPU since many of the early kernel init code is
> + * of the hotplug-lock using type.
> + */
> + if (nr < 2)
> + msleep(100);
> + else
> + msleep(5);
Hm, the limits here seem way too ad-hoc and rigid to me.
The bigger worry is that it makes the asynchronity of the boot
process very timing dependent, 'hiding' a lot of early code on
faster boxes and only interleaving the execution on slower
boxes. But slower boxes are harder to debug!
The real fix would be to make the init code depend less on each
other, i.e. have less hotplug lock dependencies. Or, if it's
such a hot lock for a good reason, why does spinning on it slow
down the boot process? It really shouldnt.
So i think this bit is not a good idea. Lets just be fully
parallel and profile early execution via 'perf kvm' or so and
figure out where the hotplug lock overhead comes from?
Thanks,
Ingo
next prev parent reply other threads:[~2012-01-31 12:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 4:54 smp: Start up non-boot CPUs asynchronously Arjan van de Ven
2012-01-31 12:52 ` Ingo Molnar [this message]
2012-01-31 13:41 ` Arjan van de Ven
2012-01-31 14:31 ` Ingo Molnar
2012-01-31 15:22 ` Arjan van de Ven
2012-01-31 16:12 ` Ingo Molnar
2012-01-31 16:24 ` Arjan van de Ven
2012-02-01 22:55 ` Andrew Morton
[not found] ` <CADyApD0yVOePmaLznks_h6xR_BCUjzEFUB7VtsL9vvsoHwCOVw@mail.gmail.com>
2012-02-01 23:31 ` Linus Torvalds
2012-02-14 8:17 ` Srivatsa S. Bhat
2012-02-14 9:48 ` Srivatsa S. Bhat
[not found] ` <CADyApD0o4UYsTkqf2H2yJZ-d05NAyRAEc6z+m1gJEogc=cZLqQ@mail.gmail.com>
2012-02-14 15:20 ` Peter Zijlstra
2012-02-14 19:57 ` Srivatsa S. Bhat
2012-02-14 20:00 ` Peter Zijlstra
2012-02-14 21:02 ` Arjan van de Ven
2012-02-14 19:32 ` Srivatsa S. Bhat
2012-02-14 21:28 ` Benjamin Herrenschmidt
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=20120131125232.GD4408@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=arjanvandeven@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miltonm@bga.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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).