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

[PATCH v2 10/10] xen/x86: add detection of memory interleaves for different nodes


  • To: <--to=xen-devel@xxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Mon, 18 Apr 2022 17:07:35 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D2YTQR4kVi07mVUXoM7ogXNLlXVpGhLewzGsT6EnZHU=; b=eXF4NlfHtEaY99c12+vK/3Zl/3X5GGv7v514hhhsu3/TObhkHxTIRGyDbaw6nV/5l7Whx8AjwcIoOdFjCY4psxeDpU/RTDoHF1+kGxJkqug0V5XzYI720EY6+0SN8XFBgOhXGNCfWg4IFQHOtYOuL2M75Nr6+fC6CMczmNT+adi6fRYe/2JlQNw3v7FJiFIi5n+x+nyhFIjLzbYjQvKwwWoF+Keaua5hQBD/XmP4nc56vZueD2BCe1b6TGrMRJpziGyh7d1l046AJrAxETV2mzCpTn+a55OLb9hm6v8YqS9d+nvtIFbTvVwmSJNVkB59PD4BkH0qFi3mnSvWT46pfw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MvMLb6QpuStdUhsJUHMdqf5n5N5A750ce+Nn1hP4hQCVok2rBbkH21A+23+cdUJMYFYsKw8zXyk2tWbqkgwjQG3S9B6COdHjqOt2wesqsM/KKmSl0PT308Sabk9rzpVUYZtESI2MzEQlgYSy2nhcZlJiMJzHxN9u6LUrQr7HJ8pt+t3MYgkcsWL1+G/hjseuPRo9KRp8jEVTweifcZJJBzWnopQJSKKGzHWpI5+GifcGYSQbIeD20WWtpBoIdzA1ZSoXg24Dj9ftUoGwx0y4HGSiOsRmzXPhBhbF0r66mqg4Rscy8+rwQ1ri6d/CEQKwwLO8wYXZ5NgzbSGtK3taMw==
  • Cc: <nd@xxxxxxx>, Wei Chen <wei.chen@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 18 Apr 2022 09:11:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

One NUMA node may contain several memory blocks. In current Xen
code, Xen will maintain a node memory range for each node to cover
all its memory blocks. But here comes the problem, in the gap of
one node's two memory blocks, if there are some memory blocks don't
belong to this node (remote memory blocks). This node's memory range
will be expanded to cover these remote memory blocks.

One node's memory range contains other nodes' memory, this is
obviously not very reasonable. This means current NUMA code only
can support node has no interleaved memory blocks. However, on a
physical machine, the addresses of multiple nodes can be interleaved.

So in this patch, we add code to detect memory interleaves of
different nodes. NUMA initialization will be failed and error
messages will be printed when Xen detect such hardware configuration.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
v1 ->v2:
1. Update the description to say we're after is no memory
   interleaves of different nodes.
2. Only update node range when it passes the interleave check.
3. Don't use full upper-case for "node".
---
 xen/arch/x86/srat.c | 49 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index c3e13059e9..53968e4085 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -271,6 +271,35 @@ acpi_numa_processor_affinity_init(const struct 
acpi_srat_cpu_affinity *pa)
                       pxm, pa->apic_id, node);
 }
 
+/*
+ * Check to see if there are other nodes within this node's range.
+ * We just need to check full contains situation. Because overlaps
+ * have been checked before by conflicting_memblks.
+ */
+static bool __init check_node_memory_interleave(nodeid_t nid,
+                                                paddr_t start, paddr_t end)
+{
+       nodeid_t i;
+       const struct node *nd = &nodes[nid];
+
+       for_each_node_mask(i, memory_nodes_parsed)
+       {
+               /* Skip itself */
+               if (i == nid)
+                       continue;
+
+               nd = &nodes[i];
+               if (start < nd->start && nd->end < end) {
+                       printk(KERN_ERR
+                              "Node %u: (%"PRIpaddr"-%"PRIpaddr") interleaves 
with node %u (%"PRIpaddr"-%"PRIpaddr")\n",
+                              nid, start, end, i, nd->start, nd->end);
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */
 void __init
 acpi_numa_memory_affinity_init(const struct acpi_srat_mem_affinity *ma)
@@ -340,10 +369,22 @@ acpi_numa_memory_affinity_init(const struct 
acpi_srat_mem_affinity *ma)
                        nd->start = start;
                        nd->end = end;
                } else {
-                       if (start < nd->start)
-                               nd->start = start;
-                       if (nd->end < end)
-                               nd->end = end;
+                       paddr_t new_start = nd->start;
+                       paddr_t new_end = nd->end;
+
+                       if (start < new_start)
+                               new_start = start;
+                       if (new_end < end)
+                               new_end = end;
+
+                       /* Check whether new range contains memory for other 
nodes */
+                       if (check_node_memory_interleave(node, new_start, 
new_end)) {
+                               bad_srat();
+                               return;
+                       }
+
+                       nd->start = new_start;
+                       nd->end = new_end;
                }
        }
        printk(KERN_INFO "SRAT: Node %u PXM %u %"PRIpaddr"-%"PRIpaddr"%s\n",
-- 
2.25.1




 


Rackspace

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