Skip to contentSkip to conversation

x86/smp: make cpu_state per-CPU

PATCH New Krystian Hebel 1 participant 2 messages Nov 14, 2023 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 x86/smp: make cpu_state per-CPU

In reply to a message not in the archive

This will be used for parallel AP bring-up.

CPU_STATE_INIT changed direction. It was previously set by BSP and never consumed by AP. Now it signals that AP got through assembly part of initialization and waits for BSP to call notifiers that set up data structures required for further initialization.

---
 xen/arch/x86/include/asm/cpufeature.h |  1 +
 xen/arch/x86/smpboot.c                | 80 ++++++++++++++++-----------
 2 files changed, 49 insertions(+), 32 deletions(-)
xen/arch/x86/include/asm/cpufeature.h +1 -0
index ff0e18864cc7..1831b5fb368f 100644
@@ -38,6 +38,7 @@ struct cpuinfo_x86 {
     unsigned int cpu_core_id;          /* core ID of each logical CPU */
     unsigned int compute_unit_id;      /* AMD compute unit ID of each logical CPU */
     void *stack_base;
+    unsigned int cpu_state;
     unsigned short x86_clflush_size;
 } __cacheline_aligned;
 
xen/arch/x86/smpboot.c +48 -32

170 lines not on this page · raw message

Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/2 x86/smp: start APs in parallel during boot

In reply to a message not in the archive

Multiple delays are required when sending IPIs and waiting for responses. During boot, 4 such IPIs were sent per each AP. With this change, only one set of broadcast IPIs is sent. This reduces boot time, especially for platforms with large number of cores.

Single CPU initialization is still possible, it is used for hotplug.

During wakeup from S3 APs are started one by one. It should be possible to enable parallel execution there as well, but I don't have a way of properly testing it as of now.

---
 xen/arch/x86/include/asm/smp.h |  1 +
 xen/arch/x86/setup.c           |  2 +
 xen/arch/x86/smpboot.c         | 68 ++++++++++++++++++++++++----------
 3 files changed, 51 insertions(+), 20 deletions(-)
xen/arch/x86/include/asm/smp.h +1 -0
index 98739028a6ed..6ca0158a368d 100644
@@ -31,6 +31,7 @@ DECLARE_PER_CPU(cpumask_var_t, send_ipi_cpumask);
 extern bool park_offline_cpus;
 
 void smp_send_nmi_allbutself(void);
+void smp_send_init_sipi_sipi_allbutself(void);
 
 void send_IPI_mask(const cpumask_t *, int vector);
 void send_IPI_self(int vector);
xen/arch/x86/setup.c +2 -0
index b2c0679725ea..42a9067b81eb 100644
@@ -1963,6 +1963,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
                 cpu_data[i].stack_base = cpu_alloc_stack(i);
         }
 
+        smp_send_init_sipi_sipi_allbutself();
+
         for_each_present_cpu ( i )
         {
             if ( (park_offline_cpus || num_online_cpus() < max_cpus) &&
xen/arch/x86/smpboot.c +48 -20

126 lines not on this page · raw message

Signature · 1 line
2.41.0