]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/smpboot: Send INIT/SIPI/SIPI to secondary CPUs in parallel
authorDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 23 Feb 2023 19:11:35 +0000 (19:11 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 27 Mar 2023 18:40:43 +0000 (19:40 +0100)
commitd7224a31d25773de3fd911d5f42b1247ad75a5fc
tree9bd783f55090072e593a7e95370a6928a06d71ee
parent3648029858274d15dc843e5388668ab86907a2a6
x86/smpboot: Send INIT/SIPI/SIPI to secondary CPUs in parallel

When the APs can find their own APIC ID without assistance, perform the
AP bringup in parallel.

Register a CPUHP_BP_PARALLEL_STARTUP stage "x86/cpu:kick" which just
calls do_boot_cpu() to deliver INIT/SIPI/SIPI to each AP in turn before
the normal native_cpu_up() does the rest of the hand-holding.

The APs will then take turns through the real mode code (which has its
own bitlock for exclusion) until they make it to their own stack, then
proceed through the first few lines of start_secondary() and execute
these parts in parallel:

 start_secondary()
    -> cr4_init()
    -> (some 32-bit only stuff so not in the parallel cases)
    -> cpu_init_secondary()
       -> cpu_init_exception_handling()
       -> cpu_init()
          -> wait_for_master_cpu()

At this point they wait for the BSP to set their bit in cpu_callout_mask
(from do_wait_cpu_initialized()), and release them to continue through
the rest of cpu_init() and beyond.

This reduces the time taken for bringup on my 28-thread Haswell system
from about 120ms to 80ms. On a socket 96-thread Skylake it takes the
bringup time from 500ms to 100ms.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Usama Arif <usama.arif@bytedance.com>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: Kim Phillips <kim.phillips@amd.com>
Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
arch/x86/kernel/smpboot.c