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

[PATCH v3 1/6] xen/x86: Provide helpers for common code to access acpi_numa


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Wei Chen <wei.chen@xxxxxxx>
  • Date: Mon, 22 Aug 2022 10:58:05 +0800
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com])
  • 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=2; 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=vsZz+zwRqqwdxZH2PQ4STiUALl22N6YfskYmd2UrzdY=; b=oNYkjCr4YpXJGoNBwfmrAXuagXxN44Wv+8kQcQdy5eHe1gfTAB0VYWGhCqNJZuxPUJEfsVo96v6F9HQzfvr+l0PP4sDa1NHcThaoacUOaS55PDgjXU7w7aBh5TxU9SJITAbiFOxtqAqXkya6iwS0SX5KHMAlueZ78INpEVAer+SsARvM8dhOMT30hTWcnZC7Zb+XnAGxb63V18ygY4dhWYFjt382+hbSjRyxWBdKbhKCST9DhDgo4W2jDbt5cGY8OhKflmmrZ8qnAw+PZAxC8FvRTEDnQJtrdDyALWIcaPBbnwZsq/bTFGGhPBjug9pVag2mMJfPAqSyaEM7HxSQyA==
  • 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=vsZz+zwRqqwdxZH2PQ4STiUALl22N6YfskYmd2UrzdY=; b=O2rdmZ4bSh8/smKkBLM+Dft424XMDixEhaRVaGh7jSKXcYk8uYZuuH0dsFJPswR13K8eJSu4nthrcLJd6rDBnwwFOAhzml5QbQ+m7Oy/Z5XRM31c6qiBRrStpkVF+l9yWxkBQW52yYV8H06BESoeNISjSQKxq2ZJBMxRhVXcEjD7Dc6eRGGrcQIntGuELdDIAi8Z2kM0NfdPMDx7daJ3K45GLpZM4GBPkM1aA4wO+rjgOB7a3qFG46eT/9YJ8I77ljlLslk+4DtxMPMSvM7kQ5BswO2gPzTas4RqE2r0aFMLzetyfdlqRNYKZZ5G2+i+sG0zcl1OPEoZO6t7356bEQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=XxCwp9zwUP5YJ+iQI+85TRKgDfCjzzSzy8fRglf6ICguYEV+cDp9C1VK2zbAjhyMz1MlT5tvf7X2k5VQRuiYJliY06NKuSPQea41cGkQJnqYAsygsIlBxomW+rUy0Wrv4UJlwVM1vhH1sGuck1Dstr/88le1RTjRXlEjrWcjgRaxXz9E2Be1OmjqbdHv7UKjR4Ge90o2/EzxxFAbIVCShPn12yHUO5Pa3RR/EE0BumFWsRfQgLylfB+0dyvrCFj3L+rsFx5XTrd6CUQjm4DLFIRN394Rl4UTu6D1AKazQ3n9Xu+FuDMnJHoRe84YFDnLvMzeCEFQlwPBmHXJ/U7g4Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b+d1a5F/2bb5Y4gJBtjxZyIAdSWmePORMMYpeSqlI6DDx1xPgtgZ+RlBw/Sr2LGgzqeQulerWaqkw/mfFpWse6Lcp4ew7uWBn9T5cTt95hBjZd6YJ01XeQXxu2rxzUWjq4QAZDz1MOdiPrE2Ovmbm5r7bncBBepJQg31rslX3+JHd/f0E7DpoyFd4p0bibjsNz0F7v4QJOw2pC1k+dN2sVCIS5GTr/IpMcUFUKh/W/oKuKn4fYxb7oqtqyENCJ4fsOkYIta88V1mA5E09vWLiUXyr6ozWNoXINkEsMqLeBat229Lj2Zzv1ob1SEoVuRXFCsUZfljtMJZEMYQnaOH7Q==
  • 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, 22 Aug 2022 02:59:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

acpi_numa is a specific NUMA switch for ACPI NUMA implementation.
Other NUMA implementation may not need this switch. But this switch is
not only used by ACPI code, it is also used directly in some general
NUMA logic code. So far this hasn't caused any problem because Xen only
has x86 implementing ACPI NUMA, but now Arm is implementing device tree
based NUMA. Accesssing acpi_numa directly in some functions will be a
block of reusing NUMA common code. It is also difficult for us to replace
it with a new generic switch, because it is hard to prove that the new
switch states can guarantee the original code will work correctly.

So in this patch, we provide two helpers for common code to update and
get states of acpi_numa. And other new NUMA implementations just need
to provide the same helpers for common code. In this case, the generic
NUMA logic code can be reused by all NUMA implementations.

Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
v2 -> v3:
1. Drop enumeration of numa status.
2. Use helpers to get/update acpi_numa.
3. Insert spaces among parameters of strncmp in numa_setup.
v1 -> v2:
1. Remove fw_numa.
2. Use enumeration to replace numa_off and acpi_numa.
3. Correct return value of srat_disabled.
4. Introduce numa_enabled_with_firmware.
---
 xen/arch/x86/include/asm/numa.h |  5 ++--
 xen/arch/x86/numa.c             | 41 ++++++++++++++++++++++-----------
 2 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/include/asm/numa.h b/xen/arch/x86/include/asm/numa.h
index c32ccffde3..f41fe20f9b 100644
--- a/xen/arch/x86/include/asm/numa.h
+++ b/xen/arch/x86/include/asm/numa.h
@@ -32,8 +32,9 @@ extern void numa_add_cpu(int cpu);
 extern void numa_init_array(void);
 extern bool numa_off;
 
-
-extern int srat_disabled(void);
+extern int arch_numa_setup(const char *opt);
+extern bool arch_numa_disabled(bool init_as_disable);
+extern bool srat_disabled(void);
 extern void numa_set_node(int cpu, nodeid_t node);
 extern nodeid_t setup_node(unsigned int pxm);
 extern void srat_detect_node(int cpu);
diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index 627ae8aa95..3d3081c967 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -50,9 +50,31 @@ nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
 bool numa_off;
 s8 acpi_numa = 0;
 
-int srat_disabled(void)
+int __init arch_numa_setup(const char *opt)
 {
-    return numa_off || acpi_numa < 0;
+#ifdef CONFIG_ACPI_NUMA
+    if ( !strncmp(opt, "noacpi", 6) )
+    {
+        numa_off = false;
+        acpi_numa = -1;
+        return 0;
+    }
+    else
+#endif
+    return -EINVAL;
+}
+
+bool arch_numa_disabled(bool init_as_disable)
+{
+    if ( !init_as_disable )
+        return acpi_numa < 0;
+
+    return acpi_numa <= 0;
+}
+
+bool srat_disabled(void)
+{
+    return numa_off || arch_numa_disabled(false);
 }
 
 /*
@@ -291,28 +313,21 @@ void numa_set_node(int cpu, nodeid_t node)
 /* [numa=off] */
 static int __init cf_check numa_setup(const char *opt)
 {
-    if ( !strncmp(opt,"off",3) )
+    if ( !strncmp(opt, "off", 3) )
         numa_off = true;
-    else if ( !strncmp(opt,"on",2) )
+    else if ( !strncmp(opt, "on", 2) )
         numa_off = false;
 #ifdef CONFIG_NUMA_EMU
     else if ( !strncmp(opt, "fake=", 5) )
     {
         numa_off = false;
-        numa_fake = simple_strtoul(opt+5,NULL,0);
+        numa_fake = simple_strtoul(opt + 5, NULL, 0);
         if ( numa_fake >= MAX_NUMNODES )
             numa_fake = MAX_NUMNODES;
     }
-#endif
-#ifdef CONFIG_ACPI_NUMA
-    else if ( !strncmp(opt,"noacpi",6) )
-    {
-        numa_off = false;
-        acpi_numa = -1;
-    }
 #endif
     else
-        return -EINVAL;
+        return arch_numa_setup(opt);
 
     return 0;
 } 
-- 
2.25.1




 


Rackspace

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