[PATCH] x86/smp: Drop booting_cpu

Andrew Cooper posted 1 patch 7 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250512120015.3445217-1-andrew.cooper3@citrix.com
xen/arch/x86/smpboot.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
[PATCH] x86/smp: Drop booting_cpu
Posted by Andrew Cooper 7 months, 1 week ago
Since commit 434596bbd44a ("x86/smpboot: Write the top-of-stack block in
cpu_smpboot_alloc()"), smp_processor_id() is unconditionally usable on APs.
Drop the global variable.

Also drop the parameter from start_secondary().  It was introduced as unused
in commit e9ac3bbccab0 ("Move initial stack-pointer adjustment into assembly
bootstrap code.") in 2005.  At the time, the caller was a shared codepath with
__start_xen() with a parameter on the stack, but that never mattered for
start_secondary() which ultimately reset_stack_and_jump()'s out of context.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/smpboot.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 54207e6d8830..49e111018224 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -226,8 +226,6 @@ static void smp_callin(void)
         cpu_relax();
 }
 
-static int booting_cpu;
-
 /* CPUs for which sibling maps can be computed. */
 static cpumask_t cpu_sibling_setup_map;
 
@@ -315,15 +313,10 @@ static void set_cpu_sibling_map(unsigned int cpu)
     }
 }
 
-void asmlinkage start_secondary(void *unused)
+void asmlinkage start_secondary(void)
 {
     struct cpu_info *info = get_cpu_info();
-
-    /*
-     * Dont put anything before smp_callin(), SMP booting is so fragile that we
-     * want to limit the things done here to the most necessary things.
-     */
-    unsigned int cpu = booting_cpu;
+    unsigned int cpu = smp_processor_id();
 
     /* Critical region without IDT or TSS.  Any fault is deadly! */
 
@@ -571,8 +564,6 @@ static int do_boot_cpu(int apicid, int cpu)
      */
     mtrr_save_state();
 
-    booting_cpu = cpu;
-
     start_eip = bootsym_phys(entry_SIPI16);
 
     /* start_eip needs be page aligned, and below the 1M boundary. */
-- 
2.39.5


Re: [PATCH] x86/smp: Drop booting_cpu
Posted by Jan Beulich 7 months, 1 week ago
On 12.05.2025 14:00, Andrew Cooper wrote:
> Since commit 434596bbd44a ("x86/smpboot: Write the top-of-stack block in
> cpu_smpboot_alloc()"), smp_processor_id() is unconditionally usable on APs.
> Drop the global variable.
> 
> Also drop the parameter from start_secondary().  It was introduced as unused
> in commit e9ac3bbccab0 ("Move initial stack-pointer adjustment into assembly
> bootstrap code.") in 2005.  At the time, the caller was a shared codepath with
> __start_xen() with a parameter on the stack, but that never mattered for
> start_secondary() which ultimately reset_stack_and_jump()'s out of context.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>