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

[XEN RFC PATCH 27/40] xen/arm: build CPU NUMA node map while creating cpu_logical_map


  • To: <wei.chen@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <jbeulich@xxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Wed, 11 Aug 2021 18:24:10 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UBGY6GfvOKpF4SmINSG8yp2SYCx1tlbM/Wi58rWpnME=; b=TNCN6Dz4152CWug8enbj2mqdlJCPc07aURosEJOPKaSGUge3KAPtv87cNoYPfKN7dJP/FvVV+dE1zwarzRv8tbMKgmslkAlxANtUylDlWM35APevMXDZ1Er3zVS4uH2cQtmnDLQs/uYQOfDcyHYDBKCI+d0o3a0gqZx7jEs+3SO2LJFq0RosjfNdNdDhunGXUlMq6IA1AMg0fSTEBwGvp3Kn2n9LjJeY+zlBjn8d4VfpvKSH/U2Dd5MOR6VFwB9x+okpR8iFLBs3PRbcs8s4kJzZrd2rBunWmNkGltI190PgUtlFOcFV2NuI5khge7k2rHJUIhNSG6xnrRzHCtWHNA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fWsmxw14xGEGX9bmdlN9/IiB4SeDhmH9of7ZXlCmUyTH2iC0zLysBAwzeyvFlH1usbwV1eNwmAEAfz2J90F5y+Zz9Y7uu5x8xKGPsj3BcCwJl6rT3b0zA0E1CWGzGVBPTwiSddWBn62+Fx2IO22IHksVIbWzEecnn/yT8yn/jnqmK5ENO/EYUtBJVU+Lf9O5tqo8spxrZ1kb5sFivP/8GWHvX87YlTJP4xg96szAbGfIjbjheXGW7oXSpjYVWbasax3ZkhuYdknAJ8vpGpQuNOGcVjyS57y7wYpDhcoOduul0WYruABnQj907tPhTGQXRKUOlVAqIFnZXnNXvDaONg==
  • Cc: <Bertrand.Marquis@xxxxxxx>
  • Delivery-date: Wed, 11 Aug 2021 10:31:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

Sometimes, CPU logical ID maybe different with physical CPU ID.
Xen is using CPU logial ID for runtime usage, so we should use
CPU logical ID to create map between NUMA node and CPU.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
 xen/arch/arm/smpboot.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index aa78958c07..dd5a45bffc 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -121,7 +121,12 @@ static void __init dt_smp_init_cpus(void)
     {
         [0 ... NR_CPUS - 1] = MPIDR_INVALID
     };
+    static nodeid_t node_map[NR_CPUS] __initdata =
+    {
+        [0 ... NR_CPUS - 1] = NUMA_NO_NODE
+    };
     bool bootcpu_valid = false;
+    uint32_t nid = 0;
     int rc;
 
     mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
@@ -172,6 +177,26 @@ static void __init dt_smp_init_cpus(void)
             continue;
         }
 
+#ifdef CONFIG_DEVICE_TREE_NUMA
+        /*
+         *  When CONFIG_DEVICE_TREE_NUMA is set, try to fetch numa infomation
+         * from CPU dts node, otherwise the nid is always 0.
+         */
+        if ( !dt_property_read_u32(cpu, "numa-node-id", &nid) )
+        {
+            printk(XENLOG_WARNING
+                "cpu[%d] dts path: %s: doesn't have numa infomation!\n",
+                cpuidx, dt_node_full_name(cpu));
+            /*
+             * The the early stage of NUMA initialization, when Xen found any
+             * CPU dts node doesn't have numa-node-id info, the NUMA will be
+             * treated as off, all CPU will be set to a FAKE node 0. So if we
+             * get numa-node-id failed here, we should set nid to 0.
+             */
+            nid = 0;
+        }
+#endif
+
         /*
          * 8 MSBs must be set to 0 in the DT since the reg property
          * defines the MPIDR[23:0]
@@ -231,9 +256,12 @@ static void __init dt_smp_init_cpus(void)
         {
             printk("cpu%d init failed (hwid %"PRIregister"): %d\n", i, hwid, 
rc);
             tmp_map[i] = MPIDR_INVALID;
+            node_map[i] = NUMA_NO_NODE;
         }
-        else
+        else {
             tmp_map[i] = hwid;
+            node_map[i] = nid;
+        }
     }
 
     if ( !bootcpu_valid )
@@ -249,6 +277,7 @@ static void __init dt_smp_init_cpus(void)
             continue;
         cpumask_set_cpu(i, &cpu_possible_map);
         cpu_logical_map(i) = tmp_map[i];
+        numa_set_node(i, node_map[i]);
     }
 }
 
-- 
2.25.1




 


Rackspace

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