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

[XEN RFC PATCH 31/40] xen/x86: move nodes_cover_memory to common


  • 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:14 +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=HWJHCCjl1hbGXNltzp/ISaOFhGhC8ThEvX0V7WgmkKA=; b=aalgA2npBGO6S+2cC0FQL4tEY4uS537fMUU3IJAcyqizi3+b+YQOuEG/iY7vZnO/ntGfyQtO4HRyBjwGhN52oBW4I+Yo5W2UuLMSxXsErSlyTxvnXhOXjA+j0BVridPx4sBGIb0NG/FhjWA9ofYk1f/KXWKax3N8dNskjpWUuE53ZP5AThsJSiqLRHybMewGICu7bxtGujI6i+Os2RiRBGe412IUVFoX2rwfUUd3//ikZvx7yR7drfzfcnkXNZoTVnbr2hgfKiW+6UWbx4YbLEuyDoIX1l+1Erh8U8jEmGeMVc5gYBTkfT6hdyhcW+yxc903ihso6+NhDiGiymbdzQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jAs/WPMFYm763HR2sLlC88pr3/kT/1QLjwlLsg1eW8SxjQPoVu5EJSWmb0lK6dO9opO7ZiD51Bf6foOAiNzQ4VtSjePXh+Q/x/loGzK52J8VKpwo0nJGFpkv9aS0i+0/XftvicTmJ7U1xC/UoeTLA0WNT9dNC+KLmVj5fd9lCzEowfoPXFjsMuQiyw0ILWjgRTp1MRENSc0X4sdeHV8doQLGbvII6HgxtR6OVOJ4ESc6nWXtoPVckODHKoq7zsouwfwlTOVBWjWKQVno6BswYguyVJNX/1nrwTNXx61AFY7M6rG37YdaQa+PgdxSF9LWweYQq+PTjzlxi5nwRkFk1A==
  • Cc: <Bertrand.Marquis@xxxxxxx>
  • Delivery-date: Wed, 11 Aug 2021 10:31:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

Not only ACPU NUMA, but also Arm device tree based NUMA
will use nodes_cover_memory to do sanity check. So we move
this function from arch/x86 to common.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
 xen/arch/x86/srat.c    | 40 ----------------------------------------
 xen/common/numa.c      | 40 ++++++++++++++++++++++++++++++++++++++++
 xen/include/xen/numa.h |  1 +
 3 files changed, 41 insertions(+), 40 deletions(-)

diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index dd3aa30843..dcebc7adec 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -308,46 +308,6 @@ acpi_numa_memory_affinity_init(const struct 
acpi_srat_mem_affinity *ma)
        num_node_memblks++;
 }
 
-/* Sanity check to catch more bad SRATs (they are amazingly common).
-   Make sure the PXMs cover all memory. */
-static int __init nodes_cover_memory(void)
-{
-       int i;
-       uint32_t nr_banks = arch_meminfo_get_nr_bank();
-
-       for (i = 0; i < nr_banks; i++) {
-               int j, found;
-               unsigned long long start, end;
-
-               if (arch_meminfo_get_ram_bank_range(i, &start, &end)) {
-                       continue;
-               }
-
-               do {
-                       found = 0;
-                       for_each_node_mask(j, memory_nodes_parsed)
-                               if (start < nodes[j].end
-                                   && end > nodes[j].start) {
-                                       if (start >= nodes[j].start) {
-                                               start = nodes[j].end;
-                                               found = 1;
-                                       }
-                                       if (end <= nodes[j].end) {
-                                               end = nodes[j].start;
-                                               found = 1;
-                                       }
-                               }
-               } while (found && start < end);
-
-               if (start < end) {
-                       printk(KERN_ERR "SRAT: No PXM for e820 range: "
-                               "%016Lx - %016Lx\n", start, end);
-                       return 0;
-               }
-       }
-       return 1;
-}
-
 void __init acpi_numa_arch_fixup(void) {}
 
 static uint64_t __initdata srat_region_mask;
diff --git a/xen/common/numa.c b/xen/common/numa.c
index 79ab250543..74960885a6 100644
--- a/xen/common/numa.c
+++ b/xen/common/numa.c
@@ -193,6 +193,46 @@ void __init cutoff_node(int i, u64 start, u64 end)
        }
 }
 
+/* Sanity check to catch more bad SRATs (they are amazingly common).
+   Make sure the PXMs cover all memory. */
+int __init nodes_cover_memory(void)
+{
+       int i;
+       uint32_t nr_banks = arch_meminfo_get_nr_bank();
+
+       for (i = 0; i < nr_banks; i++) {
+               int j, found;
+               unsigned long long start, end;
+
+               if (arch_meminfo_get_ram_bank_range(i, &start, &end)) {
+                       continue;
+               }
+
+               do {
+                       found = 0;
+                       for_each_node_mask(j, memory_nodes_parsed)
+                               if (start < nodes[j].end
+                                   && end > nodes[j].start) {
+                                       if (start >= nodes[j].start) {
+                                               start = nodes[j].end;
+                                               found = 1;
+                                       }
+                                       if (end <= nodes[j].end) {
+                                               end = nodes[j].start;
+                                               found = 1;
+                                       }
+                               }
+               } while (found && start < end);
+
+               if (start < end) {
+                       printk(KERN_ERR "SRAT: No PXM for e820 range: "
+                               "%016Lx - %016Lx\n", start, end);
+                       return 0;
+               }
+       }
+       return 1;
+}
+
 void numa_add_cpu(int cpu)
 {
     cpumask_set_cpu(cpu, &node_to_cpumask[cpu_to_node(cpu)]);
diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
index 6d18059bcd..094ab904c9 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -92,6 +92,7 @@ static inline void clear_node_cpumask(int cpu)
 extern uint32_t arch_meminfo_get_nr_bank(void);
 extern int arch_meminfo_get_ram_bank_range(int bank,
     unsigned long long *start, unsigned long long *end);
+extern int nodes_cover_memory(void);
 
 #endif /* CONFIG_NUMA */
 
-- 
2.25.1




 


Rackspace

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