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

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Mon, 1 Jun 2026 07:47:51 +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=OGUG4toyQhvtHpHBNUMbmOTNjuI/mfXhzDrcWgQ6WgQ=; b=dHU9ewvS7NF6P50AfgWziG0Cs/NhpjaqD6CefIIZO571elNmdTYSg7WAUQmfgtb6S2FgkbzLrCdLyi6LX8bQiPWmQcT7/eVkmkhMn2NyXiMJo2a+SMqG1amWVe6ErZPpNst6lG+Bf1H/AV0NlYdMfuloLM1BBIUpRsRuNXWpsVoDHSPTFWkvCYgBbhNNS+uYaTeLiRmkNpM6WU6U4avLcBEMzpfZmtZRByTLexSKt6q1R4avPD40oupGU6sol7l7mJJ1trzC5q/d9UIBgFcptvESPbpnNhAAlrFtS7469+xphajm1B3HIUAhfMToRbLFEzjooLrK6uNHcwjp/ncjeA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hcCBheyRDbuiknfa6UmHFZq6kmq2Fx8Kw8rTPWl/W9nGgHpi7f8wMGyzcm91YITjSsi3YBo5kLJZuzAUr+rtBv/2q/IpLsYvSDstKHL6uynyHOOJRlegU7BGHlEOvjd1m9IPPF45ReiM1I8+UNfjY1YjTdUAB6tUawT082gSBzDi2YvnNyYZMMrgCnmz5ykMpZnPa6MBJFrYcs01wXLtVsd7PqKxDH50i02GxHdkbnF9zdiWJlvcmyYG9cOm0k/1aG3GmEVEVPNpb60z5zElUQ7yWJyDuND9L23GIKOxopaR0LxxKnitAGR8XgiruChqmR/p+oSODKnFbBCqa6bryg==
  • 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: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Sun, 31 May 2026 22:48:47 +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 750c3d53c2..e71d6cb254 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)
 {
@@ -1568,6 +1613,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 =
@@ -1733,6 +1779,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®.