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

[PATCH v2 13/24] tools/libxl: Add 'numa-node-id' property to DomU memory nodes


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Hirokazu Takahashi <taka@xxxxxxxxxxxxx>
  • Date: Mon, 1 Jun 2026 07:47:43 +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=7/1jjuePRl2BihluZPqQwpapSqp5qYBLP0RAoKJuUMM=; b=XdPmrDFCfAHC+6bEw3AzR9ZgmdgqGVHRullXTTPhlDoW8Vh4bHw3hgvEQIfzIwmdUwtyGxqM96TrfoyucODDEZELOH6V2lzbst+8x/t5MmDPtMb/4cqiwHEar1dcMN963BuqBywW66UuMJ7VFksphg6EQrwidyXUDHIUoc30nWOKSBL7XY/nzqEtuwBVqL/JYGX5CPvbaJhh5n7LP7S7SF1iBR3K8RulQXQJXYBfo85lKtPbF+TrDMIBmR1rR313xYroU6PoRHiV4L3ZB0VBcbeT8iCEy1iwZoXFNwh+fRmRCfUznH6kEnVkEoHpfHPf9YmGqh2PrYAYA9ZlgdAs/w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qkng8pdB40bOngRy4VPOI3CpFigMMbOBmcth24d84ePYynjcrkP/4beY0urPZKOdWSGECUGsf0igmW1cw7sb81dfHZXWHMZpGP4OwNZRFW2ScWcNOi+ojE+ZBWS8m3njBI82p3Ussohowopr82RCPkNevKd+T+9frXo8B2jHTu5uft6Sqqr4mGbzCmJNu/eccrX4jmQOHvl/5dL2kgyuAOpMVWm0T7bubhpj/cjQ15Ji3VYEfSRv9YX4x8dcR5e8GIFjxZml5371aTu+crjocPIo8dQtRo8dEyfmFpsLzNBpRES3GKA2HyMHw56VvXf8YrwdcSu0INjDqZL1kpDYDg==
  • 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>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Sun, 31 May 2026 22:48:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add the 'numa-node-id' property to the memory nodes in the Device
Tree passed to DomU. The NUMA node to which each memory node
belongs is determined based on the virtual NUMA configuration
specified in the xl domain configuration file.
---
 tools/libs/light/libxl_arm.c | 50 +++++++++++++++++++++++++++++-------
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 7e9f8a1bc3..6eae33cdd2 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -670,25 +670,53 @@ static int make_optee_node(libxl__gc *gc, void *fdt)
 }
 
 static int make_memory_nodes(libxl__gc *gc, void *fdt,
+                             const libxl_domain_build_info *b_info,
                              const struct xc_dom_image *dom)
 {
     int res, i;
     const char *name;
     const uint64_t bankbase[] = GUEST_RAM_BANK_BASES;
 
-    for (i = 0; i < GUEST_RAM_BANKS; i++) {
-        name = GCSPRINTF("memory@%"PRIx64, bankbase[i]);
+    if (dom->nr_vmemranges == 0 ) {
+        for (i = 0; i < GUEST_RAM_BANKS; i++) {
+            name = GCSPRINTF("memory@%"PRIx64, bankbase[i]);
 
-        LOG(DEBUG, "Creating placeholder node /%s", name);
+            LOG(DEBUG, "Creating placeholder node /%s", name);
 
+            res = fdt_begin_node(fdt, name);
+            if (res) return res;
+
+            res = fdt_property_string(fdt, "device_type", "memory");
+            if (res) return res;
+
+            res = fdt_property_regs(gc, fdt, GUEST_ROOT_ADDRESS_CELLS, 
GUEST_ROOT_SIZE_CELLS,
+                                1, 0, 0);
+            if (res) return res;
+
+            res = fdt_end_node(fdt);
+            if (res) return res;
+        }
+
+        return 0;
+    }
+
+    for (i = 0; i < dom->nr_vmemranges; i++) {
+        uint64_t start_addr = dom->vmemranges[i].start;
+        uint64_t size = dom->vmemranges[i].end - start_addr;
+        uint32_t nid = dom->vmemranges[i].nid;
+        uint64_t regs[2] = { cpu_to_fdt64(start_addr), cpu_to_fdt64(size) };
+
+        name = GCSPRINTF("memory@%"PRIx64, start_addr);
         res = fdt_begin_node(fdt, name);
         if (res) return res;
 
         res = fdt_property_string(fdt, "device_type", "memory");
         if (res) return res;
 
-        res = fdt_property_regs(gc, fdt, GUEST_ROOT_ADDRESS_CELLS, 
GUEST_ROOT_SIZE_CELLS,
-                                1, 0, 0);
+        res = fdt_property(fdt, "reg", regs, sizeof(uint64_t) * 2);
+        if (res) return res;
+
+        res = fdt_property_u32(fdt, "numa-node-id", nid);
         if (res) return res;
 
         res = fdt_end_node(fdt);
@@ -1365,7 +1393,7 @@ next_resize:
         FDT( make_cpus_node(gc, fdt, info->max_vcpus, ainfo) );
         FDT( make_psci_node(gc, fdt) );
 
-        FDT( make_memory_nodes(gc, fdt, dom) );
+        FDT( make_memory_nodes(gc, fdt, info, dom) );
 
         switch (info->arch_arm.gic_version) {
         case LIBXL_GIC_VERSION_V2:
@@ -1716,10 +1744,14 @@ int 
libxl__arch_domain_finalise_hw_description(libxl__gc *gc,
     if (res)
         return res;
 
-    for (i = 0; i < GUEST_RAM_BANKS; i++) {
-        const uint64_t size = (uint64_t)dom->rambank_size[i] << XC_PAGE_SHIFT;
+    if (d_config->b_info.num_vnuma_nodes == 0) {
+        for (i = 0; i < GUEST_RAM_BANKS; i++) {
+            const uint64_t size = (uint64_t)dom->rambank_size[i] << 
XC_PAGE_SHIFT;
 
-        finalise_one_node(gc, fdt, "/memory", bankbase[i], size);
+            finalise_one_node(gc, fdt, "/memory", bankbase[i], size);
+        }
+    } else {
+        LOG(DEBUG, "vNUMA enabled: skipping memory node finalisation as nodes 
are already populated");
     }
 
     if (dom->acpi_modules[0].data) {
-- 
2.43.0




 


Rackspace

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