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

[PATCH 18/21] xen/arm: Generate distance-map node for Dom0 Device Tree


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Sun, 24 May 2026 09:02:06 +0900
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=valinux.co.jp; dmarc=pass action=none header.from=valinux.co.jp; dkim=pass header.d=valinux.co.jp; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=b/uOZioLySihrc5rQcsyh87OXtUbbmHXHPRWdNWOE7k=; b=dzmdEM7biGPob/YvNDpWgRfD539rCe8/NNb0MHxR3yTt1qgv41D5tgo09hM4Je9eh13SLLTNn0cweYqcgjM9yK4D7SFttZWN2+xwRu7NRoB7GVWi3xBHb404zU33fKNT/ul4sNFuOpBymh8HhYgR30w4v5Rimy61cmNnzfxUzQZxluJp1ZCATtsJKwGzAzMowhEV39Cltu5/9bkyyFbXtGFsumknaLdQ/xteUf6xVCTSSJaMMeItAsY7yuGCjgX9fjcCu8SeiSJYDZGc2hFJjo9QKq0ZgYzYKNY0C596e607P56rFdJi2czeV+X10DAqYL9nGryKN3GJOhsN2hRBBw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gk/Q7S7CeAKlgmwgwCfdPaRt22BakVe8S2IfAPLUKK+twhwI7Wdz1jN7HGncal39WydNbXhS4kQ1fKL/GShC5C7qogs76vMLqNHI5UMOKO8/JMVtP56wsdQkx86qHQX3ey3JfyOobDdLJwsCSorpwzCMwIb3lnmZgwEB6IDFtwTXJZgFoCRH37+TsVIPjpfRSLG9eU68fut9Ru3Vx8VxubzFChqgJSftDGVZQZUitUmNU2lbvLXPvvFwHqFicR/HyalNknLrJfbVu6/K+Bw+5pLKrV95GKbA03j0CXSu9neJDDbs+06v/RBJ2RXb1hMRpiGLpIppNRBciqz0fCxZcw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=valinux.co.jp header.i="@valinux.co.jp" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=valinux.co.jp;
  • Cc: andrew.cooper3@xxxxxxxxxx, anthony.perard@xxxxxxxxxx, michal.orzel@xxxxxxx, jbeulich@xxxxxxxx, julien@xxxxxxx, roger.pau@xxxxxxxxxx, sstabellini@xxxxxxxxxx, jgross@xxxxxxxx, bertrand.marquis@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, dfaggioli@xxxxxxxx, gwd@xxxxxxxxxxxxxx, Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Delivery-date: Sun, 24 May 2026 00:03:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Generate the 'distance-map' node within the Domain-0 Device Tree.
This ensures that distances are populated only for the specific NUMA
nodes assigned to Domain-0.
---
 xen/arch/arm/domain_build.c | 50 +++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 11d0fa1233..2bf4b37f89 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -718,6 +718,51 @@ static int __init fdt_property_interrupts(const struct 
kernel_info *kinfo,
     return res;
 }
 
+#ifdef CONFIG_NUMA
+static int __init make_distance_map_node(const struct domain *d, void *fdt)
+{
+    nodeid_t from, to;
+    unsigned int count = 0;
+    int res;
+
+    static uint32_t __initdata matrix[MAX_NUMNODES * MAX_NUMNODES * 3];
+
+    if ( nodes_weight(d->node_affinity) <= 1 )
+        return 0;
+
+    for_each_node_mask(from, d->node_affinity)
+    {
+        for_each_node_mask(to, d->node_affinity)
+        {
+            matrix[count * 3 + 0] = cpu_to_fdt32(from);
+            matrix[count * 3 + 1] = cpu_to_fdt32(to);
+            matrix[count * 3 + 2] = cpu_to_fdt32(__node_distance(from, to));
+            count++;
+        }
+    }
+
+    res = fdt_begin_node(fdt, "distance-map");
+    if ( res )
+        return res;
+
+    res = fdt_property_string(fdt, "compatible", "numa-distance-map-v1");
+    if ( res )
+        return res;
+
+    res = fdt_property(fdt, "distance-matrix", matrix, count * 3 * 
sizeof(uint32_t));
+    if ( res )
+        return res;
+
+    res = fdt_end_node(fdt);
+    if ( res )
+        return res;
+
+    return 0;
+}
+#else /* CONFIG_NUMA */
+#define make_distance_map_node(d, fdt) (0)
+#endif /* CONFIG_NUMA */
+
 int __init add_ext_regions(unsigned long s_gfn, unsigned long e_gfn,
                            void *data)
 {
@@ -1569,6 +1614,7 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
         DT_MATCH_TYPE("memory"),
         /* The memory mapped timer is not supported by Xen. */
         DT_MATCH_COMPATIBLE("arm,armv7-timer-mem"),
+        DT_MATCH_COMPATIBLE("numa-distance-map-v1"),
         { /* sentinel */ },
     };
     static const struct dt_device_match timer_matches[] __initconst =
@@ -1734,6 +1780,10 @@ static int __init handle_node(struct domain *d, struct 
kernel_info *kinfo,
         if ( res )
             return res;
 
+        res = make_distance_map_node(d, kinfo->fdt);
+        if ( res )
+            return res;
+
         res = sci_dt_finalize(d, kinfo->fdt);
         if ( res )
             return res;
-- 
2.43.0




 


Rackspace

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