From: Thomas Gleixner <tglx@linutronix.de>
To: David Woodhouse <dwmw2@infradead.org>,
Andy Lutomirski <luto@kernel.org>,
"shenkai \(D\)" <shenkai8@huawei.com>, "Schander\,
Johanna 'Mimoja' Amelie" <mimoja@amazon.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
hewenliang4@huawei.com, hushiyuan@huawei.com,
luolongjun@huawei.com, hejingxian@huawei.com
Subject: Re: [PATCH] use x86 cpu park to speedup smp_init in kexec situation
Date: Thu, 21 Jan 2021 15:55:51 +0100 [thread overview]
Message-ID: <877do65og8.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <8ac72d7b287ed1058b2dec3301578238aff0abdd.camel@infradead.org>
David,
On Tue, Jan 19 2021 at 12:12, David Woodhouse wrote:
> On Tue, 2020-12-15 at 22:20 +0100, Thomas Gleixner wrote:
> We've been playing with this a little. There's a proof-of-concept hack
> below; don't look too hard because it's only really for figuring out
> the timing etc.
>
> Basically we ripped out the 'wait' parts of the x86 do_boot_cpu() into
> a separate function do_wait_cpu(). There are four phases to the wait.
>
> • Wait for the AP to turn up in cpu_initialized_mask, set its bit in
> cpu_callout_mask to allow it to run the AP thread.
> • Wait for it to finish init and show up in cpu_callin_mask.
> • check_tsc_sync_source()
> • Wait for cpu_online(cpu)
>
> There's an EARLY_INIT macro which controls whether the early bringup
> call actually *does* anything, or whether it's left until bringup_cpu()
> as the current code does. It allows a simple comparison of the two.
>
> First we tested under qemu (on a Skylake EC2 c5.metal instance). The
> do_boot_cpu() actually sending the IPIs took ~300k cycles itself.
> Without EARLY_INIT we see timing for the four wait phases along the
> lines of:
>
> [ 0.285312] CPU#10 up in 192950, 952898, 60014786, 28 ( 61160662)
> [ 0.288311] CPU#11 up in 181092, 962704, 60010432, 30 ( 61154258)
> [ 0.291312] CPU#12 up in 386080, 970416, 60013956, 28 ( 61370480)
> [ 0.294311] CPU#13 up in 372782, 964506, 60010564, 28 ( 61347880)
> [ 0.297312] CPU#14 up in 389602, 976280, 60013046, 28 ( 61378956)
> [ 0.300312] CPU#15 up in 213132, 968148, 60012138, 28 ( 61193446)
>
> If we define EARLY_INIT then that first phase of waiting for the CPU
> add itself is fairly much instantaneous, which is precisely what we
> were hoping for. We also seem to save about 300k cycles on the AP
> bringup too. It's just that it *all* pales into insignificance with
> whatever it's doing to synchronise the TSC for 60M cycles.
Yes, that's annoying, but it can be avoided. The host could tell the
guest that the TSC is perfectly synced.
> [ 0.338829] CPU#10 up in 600, 689054, 60025522, 28 ( 60715204)
> [ 0.341829] CPU#11 up in 610, 635346, 60019390, 28 ( 60655374)
> [ 0.343829] CPU#12 up in 632, 619352, 60020728, 28 ( 60640740)
> [ 0.346829] CPU#13 up in 602, 514234, 60025402, 26 ( 60540264)
> [ 0.348830] CPU#14 up in 608, 621058, 60025952, 26 ( 60647644)
> [ 0.351829] CPU#15 up in 600, 624690, 60021526, 410 ( 60647226)
>
> Testing on real hardware has been more interesting and less useful so
> far. We started with the CPUHP_BRINGUP_KICK_CPU state being
> *immediately* before CPUHP_BRINGUP_CPU. On my 28-thread Haswell box,
> that didn't come up at all even without actually *doing* anything in
> the pre-bringup phase. Merely bringing all the AP threads up through
> the various CPUHP_PREPARE_foo stages before actually bringing them
> online, was enough to break it. I have no serial port on this box so we
> haven't get worked out why; I've resorted to putting the
> CPUHP_BRINGUP_KICK_CPU state before CPUHP_WORKQUEUE_PREP instead.
Hrm.
> That lets it boot without the EARLY_INIT at least (so it's basically a
> no-op), and I get these timings. Looks like there's 3-4M cycles to be
> had by the parallel SIPI/INIT, but the *first* thread of each core is
> also taking another 8M cycles and it might be worth doing *those* in
> parallel too. And Thomas I think that waiting for the AP to bring
> itself up is the part you meant was pointlessly differently
> reimplemented across architectures? So the way forward there might be
> to offer a generic CPUHP state for that, for architectures to plug into
> and ditch their own tracking.
Yes. The whole wait for alive and callin and online can be generic.
> When I enabled EARLY_INIT it didn't boot; I need to hook up some box
> with a serial port to make more meaningful progress there, but figured
> it was worth sharing the findings so far.
>
> Here's the hack we're testing with, for reference. It's kind of ugly
> but you can see where it's going. Note that the CMOS mangling for the
> warm reset vector is going to need to be lifted out of the per-cpu
> loop, and done *once* at startup and torn down once in smp_cpus_done.
> Except that it also needs to be done before/after a hotplug cpu up;
> we'll have to come back to that but we've just shifted it to
> native_smp_cpus_done() for testing for now.
Right. It's at least a start.
Thanks,
tglx
next prev parent reply other threads:[~2021-01-21 14:58 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 14:46 shenkai (D)
2020-12-15 16:31 ` Andy Lutomirski
2020-12-15 21:20 ` Thomas Gleixner
2020-12-16 8:45 ` shenkai (D)
2020-12-16 10:12 ` Thomas Gleixner
2020-12-16 14:18 ` shenkai (D)
2020-12-16 15:31 ` Thomas Gleixner
2020-12-17 14:53 ` shenkai (D)
2021-01-07 15:18 ` David Woodhouse
2021-01-19 12:12 ` David Woodhouse
2021-01-21 14:55 ` Thomas Gleixner [this message]
2021-01-21 15:42 ` David Woodhouse
2021-01-21 17:34 ` David Woodhouse
2021-01-21 19:59 ` [PATCH] x86/apic/x2apic: Fix parallel handling of cluster_mask David Woodhouse
2021-02-01 10:36 ` [PATCH] use x86 cpu park to speedup smp_init in kexec situation David Woodhouse
2021-02-01 10:38 ` [PATCH 1/6] x86/apic/x2apic: Fix parallel handling of cluster_mask David Woodhouse
2021-02-01 10:38 ` [PATCH 2/6] cpu/hotplug: Add dynamic states before CPUHP_BRINGUP_CPU for parallel bringup David Woodhouse
2021-02-01 10:38 ` [PATCH 3/6] x86/smpboot: Reference count on smpboot_setup_warm_reset_vector() David Woodhouse
2021-02-01 10:38 ` [PATCH 4/6] x86/smpboot: Split up native_cpu_up into separate phases David Woodhouse
2021-02-01 10:38 ` [PATCH 5/6] cpu/hotplug: Move idle_thread_get() to <linux/smpboot.h> David Woodhouse
2021-02-01 10:38 ` [PATCH 6/6] pre states for x86 David Woodhouse
[not found] <87ft22dxop.fsf@nanos.tec.linutronix.de>
[not found] ` <27357c74bdc3b52bdf59e6f48cd8690495116d64.camel@infradead.org>
[not found] ` <877dnedt7l.fsf@nanos.tec.linutronix.de>
[not found] ` <87zh09tcqz.fsf@nanos.tec.linutronix.de>
2021-02-16 13:53 ` [PATCH] use x86 cpu park to speedup smp_init in kexec situation David Woodhouse
2021-02-16 15:10 ` David Woodhouse
2021-02-16 21:18 ` David Woodhouse
2021-12-08 14:14 ` David Woodhouse
2021-12-08 14:50 ` Paul E. McKenney
2021-12-08 15:10 ` David Woodhouse
2021-12-08 16:57 ` David Woodhouse
2021-12-08 17:35 ` Paul E. McKenney
2021-12-08 18:32 ` David Woodhouse
2021-12-08 19:03 ` Paul E. McKenney
2021-12-08 20:35 ` David Woodhouse
2021-12-08 21:09 ` Paul E. McKenney
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=877do65og8.fsf@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=bp@alien8.de \
--cc=dwmw2@infradead.org \
--cc=hejingxian@huawei.com \
--cc=hewenliang4@huawei.com \
--cc=hpa@zytor.com \
--cc=hushiyuan@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luolongjun@huawei.com \
--cc=luto@kernel.org \
--cc=mimoja@amazon.com \
--cc=mingo@redhat.com \
--cc=shenkai8@huawei.com \
--cc=x86@kernel.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
Powered by JetHome