[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/arm: Fix sibling mask setup to only include online CPUs



commit f1b08cc03aceeb49000b0521a7a884c607a57fb5
Author:     Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
AuthorDate: Fri Nov 27 06:45:05 2026 +0100
Commit:     Michal Orzel <michal.orzel@xxxxxxx>
CommitDate: Fri Nov 27 12:10:24 2026 +0100

    xen/arm: Fix sibling mask setup to only include online CPUs
    
    Populate the CPU sibling masks only with CPUs that are brought
    up, and remove a CPU from the masks when it goes down.
    Currently, all CPUs in cpu_possible_map are added to the masks
    at boot time, which leaves CPUs that failed to boot in the sibling
    masks and may lead the scheduler to make incorrect decisions.
    
    Fixes: 701190abb3d5 ("xen/arm: Set correct per-cpu cpu_core_mask")
    Signed-off-by: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/smpboot.c | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 8c9072f3c1..2fc6c36ca1 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -91,15 +91,38 @@ static int setup_cpu_sibling_map(int cpu)
          !zalloc_cpumask_var(&per_cpu(cpu_core_mask, cpu)) )
         return -ENOMEM;
 
+    return 0;
+}
+
+static void set_cpu_sibling_map(unsigned int cpu)
+{
+    unsigned int sibling;
+
+    BUG_ON(!per_cpu(cpu_sibling_mask, cpu));
+    BUG_ON(!per_cpu(cpu_core_mask, cpu));
+
     /*
      * Currently we assume there is no multithread and NUMA, so
-     * a CPU is a sibling with itself, and the all possible CPUs
+     * a CPU is a sibling with itself, and the all online CPUs
      * are supposed to belong to the same socket (NUMA node).
      */
     cpumask_set_cpu(cpu, per_cpu(cpu_sibling_mask, cpu));
-    cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_possible_map);
+    cpumask_copy(per_cpu(cpu_core_mask, cpu), &cpu_online_map);
+    cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, cpu));
 
-    return 0;
+    for_each_online_cpu(sibling)
+        cpumask_set_cpu(cpu, per_cpu(cpu_core_mask, sibling));
+}
+
+static void remove_siblinginfo(unsigned int cpu)
+{
+    unsigned int sibling;
+
+    for_each_cpu(sibling, per_cpu(cpu_core_mask, cpu))
+        cpumask_clear_cpu(cpu, per_cpu(cpu_core_mask, sibling));
+
+    cpumask_clear(per_cpu(cpu_sibling_mask, cpu));
+    cpumask_clear(per_cpu(cpu_core_mask, cpu));
 }
 
 static void remove_cpu_sibling_map(int cpu)
@@ -314,6 +337,7 @@ smp_prepare_cpus(void)
     if ( rc )
         panic("Unable to allocate CPU sibling/core maps\n");
 
+    set_cpu_sibling_map(0);
 }
 
 /* Boot the current CPU */
@@ -385,6 +409,8 @@ void asmlinkage noreturn start_secondary(void)
 
     set_current(idle_vcpu[cpuid]);
 
+    set_cpu_sibling_map(cpuid);
+
     /* Run local notifiers */
     notify_cpu_starting(cpuid);
     /*
@@ -431,6 +457,8 @@ void __cpu_disable(void)
     mdelay(1);
     local_irq_disable();
 
+    remove_siblinginfo(cpu);
+
     /* It's now safe to remove this processor from the online map */
     cpumask_clear_cpu(cpu, &cpu_online_map);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.