linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [patch V2 00/38] cpu/hotplug, x86: Reworked parallel CPU bringup
@ 2023-05-04 19:01 Thomas Gleixner
  2023-05-04 19:02 ` [patch V2 01/38] x86/smpboot: Cleanup topology_phys_to_logical_pkg()/die() Thomas Gleixner
                   ` (37 more replies)
  0 siblings, 38 replies; 44+ messages in thread
From: Thomas Gleixner @ 2023-05-04 19:01 UTC (permalink / raw)
  To: LKML
  Cc: x86, David Woodhouse, Andrew Cooper, Brian Gerst,
	Arjan van de Veen, Paolo Bonzini, Paul McKenney, Tom Lendacky,
	Sean Christopherson, Oleksandr Natalenko, Paul Menzel,
	Guilherme G. Piccoli, Piotr Gorski, Usama Arif, Juergen Gross,
	Boris Ostrovsky, xen-devel, Russell King, Arnd Bergmann,
	linux-arm-kernel, Catalin Marinas, Will Deacon, Guo Ren,
	linux-csky, Thomas Bogendoerfer, linux-mips, James E.J. Bottomley,
	Helge Deller, linux-parisc, Paul Walmsley, Palmer Dabbelt,
	linux-riscv, Mark Rutland, Sabin Rapan, Michael Kelley (LINUX)

Hi!

This is version 2 of the reworked parallel bringup series. Version 1 can be
found here:

   https://lore.kernel.org/lkml/20230414225551.858160935@linutronix.de

Background
----------

The reason why people are interested in parallel bringup is to shorten the
(kexec) reboot time of cloud servers to reduce the downtime of the VM
tenants.

The current fully serialized bringup does the following per AP:

    1) Prepare callbacks (allocate, intialize, create threads)
    2) Kick the AP alive (e.g. INIT/SIPI on x86)
    3) Wait for the AP to report alive state
    4) Let the AP continue through the atomic bringup
    5) Let the AP run the threaded bringup to full online state

There are two significant delays:

    #3 The time for an AP to report alive state in start_secondary() on x86
       has been measured in the range between 350us and 3.5ms depending on
       vendor and CPU type, BIOS microcode size etc.

    #4 The atomic bringup does the microcode update. This has been measured
       to take up to ~8ms on the primary threads depending on the microcode
       patch size to apply.

On a two socket SKL server with 56 cores (112 threads) the boot CPU spends
on current mainline about 800ms busy waiting for the APs to come up and
apply microcode. That's more than 80% of the actual onlining procedure.

By splitting the actual bringup mechanism into two parts this can be
reduced to waiting for the first AP to report alive or if the system is
large enough the first AP is already waiting when the boot CPU finished the
wake-up of the last AP. That reduces the AP bringup time on that SKL from
~800ms to ~80ms.

The actual gain varies wildly depending on the system, CPU, microcode patch
size and other factors.

The V1 cover letter has more details and a deep analysis.

Changes vs. V1:

  1) Switch APIC ID retrieval from CPUID to reading the APIC itself.

     This is required because CPUID based APIC ID retrieval can only
     provide the initial APIC ID, which might have been overruled by the
     firmware. Some AMD APUs come up with APIC ID = initial APIC ID + 0x10,
     so the APIC ID to CPU number lookup would fail miserably if based on
     CPUID. The only requirement is that the actual APIC IDs are consistent
     with the APCI/MADT table.

  2) As a consequence of #1 parallel bootup support for SEV guest has been
     dropped.

     Reading the APIC ID in a SEV guest is done via RDMSR. That RDMSR is
     intercepted and raises #VC which cannot be handled at that point as
     there is no stack and no IDT. There is no GHCB protocol for RDMSR
     like there is for CPUID. Left as an exercise for SEV wizards.

  3) Address review comments from Brian and the fallout reported by the
     kernel robot

  4) Unbreak i386 which exploded when bringing up the secondary CPUs due to
     the unconditinal load_ucode_ap() invocation in start_secondary(). That
     happens because on 32-bit load_ucode_ap() is invoked on the secondary
     CPUs from assembly code before paging is initialized and therefore
     uses physical addresses which are obviously invalid after paging is
     enabled.

  5) Small enhancements and comment updates.

  6) Rebased on Linux tree (1a5304fecee5)

The series applies on Linus tree and is also available from git:

    git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git hotplug

Thanks,

	tglx
---
 Documentation/admin-guide/kernel-parameters.txt |   20 
 Documentation/core-api/cpu_hotplug.rst          |   13 
 arch/Kconfig                                    |   23 +
 arch/arm/Kconfig                                |    1 
 arch/arm/include/asm/smp.h                      |    2 
 arch/arm/kernel/smp.c                           |   18 
 arch/arm64/Kconfig                              |    1 
 arch/arm64/include/asm/smp.h                    |    2 
 arch/arm64/kernel/smp.c                         |   14 
 arch/csky/Kconfig                               |    1 
 arch/csky/include/asm/smp.h                     |    2 
 arch/csky/kernel/smp.c                          |    8 
 arch/mips/Kconfig                               |    1 
 arch/mips/cavium-octeon/smp.c                   |    1 
 arch/mips/include/asm/smp-ops.h                 |    1 
 arch/mips/kernel/smp-bmips.c                    |    1 
 arch/mips/kernel/smp-cps.c                      |   14 
 arch/mips/kernel/smp.c                          |    8 
 arch/mips/loongson64/smp.c                      |    1 
 arch/parisc/Kconfig                             |    1 
 arch/parisc/kernel/process.c                    |    4 
 arch/parisc/kernel/smp.c                        |    7 
 arch/riscv/Kconfig                              |    1 
 arch/riscv/include/asm/smp.h                    |    2 
 arch/riscv/kernel/cpu-hotplug.c                 |   14 
 arch/x86/Kconfig                                |   45 --
 arch/x86/include/asm/apic.h                     |    5 
 arch/x86/include/asm/apicdef.h                  |    5 
 arch/x86/include/asm/cpu.h                      |    5 
 arch/x86/include/asm/cpumask.h                  |    5 
 arch/x86/include/asm/processor.h                |    1 
 arch/x86/include/asm/realmode.h                 |    3 
 arch/x86/include/asm/smp.h                      |   24 -
 arch/x86/include/asm/topology.h                 |   23 -
 arch/x86/include/asm/tsc.h                      |    2 
 arch/x86/kernel/acpi/sleep.c                    |    9 
 arch/x86/kernel/apic/apic.c                     |   26 -
 arch/x86/kernel/callthunks.c                    |    4 
 arch/x86/kernel/cpu/amd.c                       |    2 
 arch/x86/kernel/cpu/cacheinfo.c                 |   21 
 arch/x86/kernel/cpu/common.c                    |   50 --
 arch/x86/kernel/cpu/topology.c                  |    3 
 arch/x86/kernel/head_32.S                       |   14 
 arch/x86/kernel/head_64.S                       |   87 +++
 arch/x86/kernel/sev.c                           |    2 
 arch/x86/kernel/smp.c                           |    3 
 arch/x86/kernel/smpboot.c                       |  526 ++++++++----------------
 arch/x86/kernel/topology.c                      |   98 ----
 arch/x86/kernel/tsc.c                           |   20 
 arch/x86/kernel/tsc_sync.c                      |   36 -
 arch/x86/power/cpu.c                            |   37 -
 arch/x86/realmode/init.c                        |    3 
 arch/x86/realmode/rm/trampoline_64.S            |   27 +
 arch/x86/xen/enlighten_hvm.c                    |   11 
 arch/x86/xen/smp_hvm.c                          |   16 
 arch/x86/xen/smp_pv.c                           |   56 +-
 drivers/acpi/processor_idle.c                   |    4 
 include/linux/cpu.h                             |    4 
 include/linux/cpuhotplug.h                      |   17 
 kernel/cpu.c                                    |  396 +++++++++++++++++-
 kernel/smp.c                                    |    2 
 kernel/smpboot.c                                |  163 -------
 62 files changed, 934 insertions(+), 982 deletions(-)

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2023-05-07  4:15 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-04 19:01 [patch V2 00/38] cpu/hotplug, x86: Reworked parallel CPU bringup Thomas Gleixner
2023-05-04 19:02 ` [patch V2 01/38] x86/smpboot: Cleanup topology_phys_to_logical_pkg()/die() Thomas Gleixner
2023-05-04 19:02 ` [patch V2 02/38] cpu/hotplug: Mark arch_disable_smp_support() and bringup_nonboot_cpus() __init Thomas Gleixner
2023-05-04 19:02 ` [patch V2 03/38] x86/smpboot: Avoid pointless delay calibration if TSC is synchronized Thomas Gleixner
2023-05-04 19:02 ` [patch V2 04/38] x86/smpboot: Rename start_cpu0() to soft_restart_cpu() Thomas Gleixner
2023-05-04 19:02 ` [patch V2 05/38] x86/topology: Remove CPU0 hotplug option Thomas Gleixner
2023-05-04 19:02 ` [patch V2 06/38] x86/smpboot: Remove the CPU0 hotplug kludge Thomas Gleixner
2023-05-04 19:02 ` [patch V2 07/38] x86/smpboot: Restrict soft_restart_cpu() to SEV Thomas Gleixner
2023-05-04 19:02 ` [patch V2 08/38] x86/smpboot: Split up native_cpu_up() into separate phases and document them Thomas Gleixner
2023-05-04 19:02 ` [patch V2 09/38] x86/smpboot: Get rid of cpu_init_secondary() Thomas Gleixner
2023-05-04 19:02 ` [patch V2 10/38] x86/cpu/cacheinfo: Remove cpu_callout_mask dependency Thomas Gleixner
2023-05-04 19:02 ` [patch V2 11/38] x86/smpboot: Move synchronization masks to SMP boot code Thomas Gleixner
2023-05-04 19:02 ` [patch V2 12/38] x86/smpboot: Make TSC synchronization function call based Thomas Gleixner
2023-05-04 19:02 ` [patch V2 13/38] x86/smpboot: Remove cpu_callin_mask Thomas Gleixner
2023-05-04 19:02 ` [patch V2 14/38] cpu/hotplug: Rework sparse_irq locking in bringup_cpu() Thomas Gleixner
2023-05-04 19:02 ` [patch V2 15/38] x86/smpboot: Remove wait for cpu_online() Thomas Gleixner
2023-05-04 19:02 ` [patch V2 16/38] x86/xen/smp_pv: Remove wait for CPU online Thomas Gleixner
2023-05-04 19:02 ` [patch V2 17/38] x86/xen/hvm: Get rid of DEAD_FROZEN handling Thomas Gleixner
2023-05-04 19:02 ` [patch V2 18/38] cpu/hotplug: Add CPU state tracking and synchronization Thomas Gleixner
2023-05-04 19:02 ` [patch V2 19/38] x86/smpboot: Switch to hotplug core state synchronization Thomas Gleixner
2023-05-04 19:02 ` [patch V2 20/38] cpu/hotplug: Remove cpu_report_state() and related unused cruft Thomas Gleixner
2023-05-04 19:02 ` [patch V2 21/38] ARM: smp: Switch to hotplug core state synchronization Thomas Gleixner
2023-05-04 19:02 ` [patch V2 22/38] arm64: " Thomas Gleixner
2023-05-04 19:02 ` [patch V2 23/38] csky/smp: " Thomas Gleixner
2023-05-04 19:02 ` [patch V2 24/38] MIPS: SMP_CPS: " Thomas Gleixner
2023-05-04 19:02 ` [patch V2 25/38] parisc: " Thomas Gleixner
2023-05-04 19:02 ` [patch V2 26/38] riscv: " Thomas Gleixner
2023-05-04 19:02 ` [patch V2 27/38] cpu/hotplug: Remove unused state functions Thomas Gleixner
2023-05-04 19:02 ` [patch V2 28/38] cpu/hotplug: Reset task stack state in _cpu_up() Thomas Gleixner
2023-05-04 19:02 ` [patch V2 29/38] cpu/hotplug: Provide a split up CPUHP_BRINGUP mechanism Thomas Gleixner
2023-05-04 19:02 ` [patch V2 30/38] x86/smpboot: Enable split CPU startup Thomas Gleixner
2023-05-04 19:02 ` [patch V2 31/38] x86/apic: Provide cpu_primary_thread mask Thomas Gleixner
2023-05-04 19:02 ` [patch V2 32/38] cpu/hotplug: Allow "parallel" bringup up to CPUHP_BP_KICK_AP_STATE Thomas Gleixner
2023-05-04 19:02 ` [patch V2 33/38] x86/topology: Store extended topology leaf information Thomas Gleixner
2023-05-04 19:02 ` [patch V2 34/38] x86/cpu/amd; Invoke detect_extended_topology_early() on boot CPU Thomas Gleixner
2023-05-04 23:04   ` Andrew Cooper
2023-05-05 12:45     ` Thomas Gleixner
2023-05-04 19:02 ` [patch V2 35/38] x86/apic: Save the APIC virtual base address Thomas Gleixner
2023-05-04 19:02 ` [patch V2 36/38] x86/smpboot: Implement a bit spinlock to protect the realmode stack Thomas Gleixner
2023-05-04 19:02 ` [patch V2 37/38] x86/smpboot: Support parallel startup of secondary CPUs Thomas Gleixner
2023-05-04 19:03 ` [patch V2 38/38] x86/smpboot/64: Implement arch_cpuhp_init_parallel_bringup() and enable it Thomas Gleixner
2023-05-06  0:53   ` Michael Kelley (LINUX)
2023-05-06 16:22     ` Thomas Gleixner
2023-05-07  4:14       ` Michael Kelley (LINUX)

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