All of lore.kernel.org
 help / color / mirror / Atom feed
From: vijay.kilari@gmail.com
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
	George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com,
	jbeulich@suse.com, Vijaya Kumar K <Vijaya.Kumar@cavium.com>
Subject: [RFC PATCH v2 15/25] ARM: NUMA: Add CPU NUMA support
Date: Tue, 28 Mar 2017 21:23:23 +0530	[thread overview]
Message-ID: <1490716413-19796-16-git-send-email-vijay.kilari@gmail.com> (raw)
In-Reply-To: <1490716413-19796-1-git-send-email-vijay.kilari@gmail.com>

From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>

For each cpu, update cpu_to_node[] with node id from
the numa-node-id DT property. Also, initialize cpu_to_node[]
with node 0.

Add macros to access cpu_to_node[] information.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
---
 xen/arch/arm/numa/numa.c   | 21 +++++++++++++++++++++
 xen/arch/arm/smpboot.c     | 25 ++++++++++++++++++++++++-
 xen/include/asm-arm/numa.h | 24 ++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/numa/numa.c b/xen/arch/arm/numa/numa.c
index 0ee89da..eef5870 100644
--- a/xen/arch/arm/numa/numa.c
+++ b/xen/arch/arm/numa/numa.c
@@ -28,6 +28,25 @@ static uint8_t (*node_distance_fn)(nodeid_t a, nodeid_t b);
 extern nodemask_t processor_nodes_parsed;
 static bool_t dt_numa = 1;
 
+/*
+ * Setup early cpu_to_node.
+ */
+void __init init_cpu_to_node(void)
+{
+    int i;
+
+    for ( i = 0; i < NR_CPUS; i++ )
+        numa_set_node(i, 0);
+}
+
+void __init numa_set_cpu_node(int cpu, unsigned int nid)
+{
+    if ( !node_isset(nid, processor_nodes_parsed) || nid >= MAX_NUMNODES )
+        nid = 0;
+
+    numa_set_node(cpu, nid);
+}
+
 uint8_t __node_distance(nodeid_t a, nodeid_t b)
 {
     if ( node_distance_fn != NULL);
@@ -48,6 +67,7 @@ void numa_failed(void)
     dt_numa = 0;
     init_dt_numa_distance();
     node_distance_fn = NULL;
+    init_cpu_to_node();
 }
 
 void __init numa_init(void)
@@ -55,6 +75,7 @@ void __init numa_init(void)
     int ret = 0;
 
     nodes_clear(processor_nodes_parsed);
+    init_cpu_to_node();
     init_dt_numa_distance();
     if ( is_numa_off() )
         goto no_numa;
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 32e8722..bf7ddaf 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -29,6 +29,7 @@
 #include <xen/timer.h>
 #include <xen/irq.h>
 #include <xen/console.h>
+#include <xen/numa.h>
 #include <asm/cpuerrata.h>
 #include <asm/gic.h>
 #include <asm/psci.h>
@@ -106,6 +107,7 @@ static void __init dt_smp_init_cpus(void)
         [0 ... NR_CPUS - 1] = MPIDR_INVALID
     };
     bool_t bootcpu_valid = 0;
+    nodeid_t *cpu_to_nodemap;
     int rc;
 
     mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
@@ -117,11 +119,18 @@ static void __init dt_smp_init_cpus(void)
         return;
     }
 
+    cpu_to_nodemap = xzalloc_array(nodeid_t, NR_CPUS);
+    if ( !cpu_to_nodemap )
+    {
+        printk(XENLOG_WARNING "Failed to allocate memory for cpu_to_nodemap\n");
+        return;
+    }
+
     dt_for_each_child_node( cpus, cpu )
     {
         const __be32 *prop;
         u64 addr;
-        u32 reg_len;
+        u32 reg_len, nid;
         register_t hwid;
 
         if ( !dt_device_type_is_equal(cpu, "cpu") )
@@ -146,6 +155,15 @@ static void __init dt_smp_init_cpus(void)
             continue;
         }
 
+        if ( !dt_property_read_u32(cpu, "numa-node-id", &nid) )
+        {
+            printk(XENLOG_WARNING "cpu node `%s`: numa-node-id not found\n",
+                   dt_node_full_name(cpu));
+            nid = 0;
+        }
+
+        cpu_to_nodemap[cpuidx] = nid;
+
         addr = dt_read_number(prop, dt_n_addr_cells(cpu));
 
         hwid = addr;
@@ -224,6 +242,7 @@ static void __init dt_smp_init_cpus(void)
     {
         printk(XENLOG_WARNING "DT missing boot CPU MPIDR[23:0]\n"
                "Using only 1 CPU\n");
+        xfree(cpu_to_nodemap);
         return;
     }
 
@@ -233,7 +252,10 @@ static void __init dt_smp_init_cpus(void)
             continue;
         cpumask_set_cpu(i, &cpu_possible_map);
         cpu_logical_map(i) = tmp_map[i];
+        numa_set_cpu_node(i, cpu_to_nodemap[i]);
     }
+
+    xfree(cpu_to_nodemap);
 }
 
 void __init smp_init_cpus(void)
@@ -313,6 +335,7 @@ void start_secondary(unsigned long boot_phys_offset,
      */
     smp_wmb();
 
+    numa_add_cpu(cpuid);
     /* Now report this CPU is up */
     cpumask_set_cpu(cpuid, &cpu_online_map);
 
diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h
index c390a0e..65bdd5e 100644
--- a/xen/include/asm-arm/numa.h
+++ b/xen/include/asm-arm/numa.h
@@ -14,12 +14,36 @@ extern uint8_t __node_distance(nodeid_t a, nodeid_t b);
 #ifdef CONFIG_NUMA
 extern void numa_init(void);
 extern int dt_numa_init(void);
+extern void numa_set_cpu_node(int cpu, unsigned int nid);
+extern void numa_add_cpu(int cpu);
+
+extern nodeid_t      cpu_to_node[NR_CPUS];
+extern cpumask_t     node_to_cpumask[];
+/* Simple perfect hash to map pdx to node numbers */
+extern unsigned int memnode_shift;
+extern uint8_t *memnodemap;
+
+#define cpu_to_node(cpu)         (cpu_to_node[cpu])
+#define parent_node(node)        (node)
+#define node_to_first_cpu(node)  (__ffs(node_to_cpumask[node]))
+#define node_to_cpumask(node)    (node_to_cpumask[node])
+
 #else
 static inline void numa_init(void)
 {
     return;
 }
 
+static inline void numa_set_cpu_node(int cpu, unsigned int nid)
+{
+    return;
+}
+
+static inline void numa_add_cpu(int cpu)
+{
+     return;
+}
+
 /* Fake one node for now. See also node_online_map. */
 #define cpu_to_node(cpu) 0
 #define node_to_cpumask(node)   (cpu_online_map)
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-03-28 15:53 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 15:53 [RFC PATCH v2 00/25] ARM: Add Xen NUMA support vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 01/25] x86: NUMA: Clean up: Drop trailing spaces vijay.kilari
2017-03-28 16:44   ` Wei Liu
2017-05-31 10:20   ` Jan Beulich
2017-05-31 10:21   ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 02/25] x86: NUMA: Fix datatypes and attributes vijay.kilari
2017-03-28 16:44   ` Wei Liu
2017-05-31 10:35   ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 03/25] x86: NUMA: Rename and sanitize some common functions vijay.kilari
2017-06-30 14:05   ` Jan Beulich
2017-07-11 10:16     ` Vijay Kilari
2017-03-28 15:53 ` [RFC PATCH v2 04/25] x86: NUMA: Add accessors for acpi_numa, numa_off and numa_fake variables vijay.kilari
2017-04-20 15:59   ` Julien Grall
2017-04-25  6:54     ` Vijay Kilari
2017-04-25 12:04       ` Julien Grall
2017-04-25 12:20         ` Vijay Kilari
2017-04-25 12:28           ` Julien Grall
2017-04-25 14:54             ` Vijay Kilari
2017-04-25 15:14               ` Julien Grall
2017-04-25 15:43                 ` Jan Beulich
2017-05-02  9:47                   ` Vijay Kilari
2017-05-02  9:54                     ` Jan Beulich
2017-05-08 17:38                     ` Julien Grall
2017-06-30 14:07   ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 05/25] x86: NUMA: Move generic dummy_numa_init to separate function vijay.kilari
2017-04-20 16:12   ` Julien Grall
2017-04-25  6:59     ` Vijay Kilari
2017-06-30 14:08   ` Jan Beulich
2017-03-28 15:53 ` [RFC PATCH v2 06/25] x86: NUMA: Add accessors for nodes[] and node_memblk_range[] structs vijay.kilari
2017-05-08 14:39   ` Julien Grall
2017-05-09  7:02     ` Vijay Kilari
2017-05-09  8:13       ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 07/25] x86: NUMA: Rename some generic functions vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 08/25] x86: NUMA: Sanitize node distance vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 09/25] ARM: NUMA: Add existing ARM numa code under CONFIG_NUMA vijay.kilari
2017-05-08 15:58   ` Julien Grall
2017-05-09  7:14     ` Vijay Kilari
2017-05-09  8:21       ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 10/25] x86: NUMA: Move numa code and make it generic vijay.kilari
2017-05-08 16:41   ` Julien Grall
2017-05-09  7:36     ` Vijay Kilari
2017-05-09  8:23       ` Julien Grall
2017-05-08 16:51   ` Julien Grall
2017-05-09  7:39     ` Vijay Kilari
2017-05-09  8:26       ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 11/25] x86: NUMA: Move common code from srat.c vijay.kilari
2017-05-08 17:06   ` Julien Grall
2017-05-10  9:00     ` Vijay Kilari
2017-03-28 15:53 ` [RFC PATCH v2 12/25] ARM: NUMA: Parse CPU NUMA information vijay.kilari
2017-05-08 17:31   ` Julien Grall
2017-05-10  5:24     ` Vijay Kilari
2017-05-10  8:52       ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 13/25] ARM: NUMA: Parse memory " vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 14/25] ARM: NUMA: Parse NUMA distance information vijay.kilari
2017-03-28 15:53 ` vijay.kilari [this message]
2017-03-28 15:53 ` [RFC PATCH v2 16/25] ARM: NUMA: Add memory NUMA support vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 17/25] ARM: NUMA: Add fallback on NUMA failure vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 18/25] ARM: NUMA: Do not expose numa info to DOM0 vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 19/25] ACPI: Refactor acpi SRAT and SLIT table handling code vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 20/25] ARM: NUMA: Extract MPIDR from MADT table vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 21/25] ACPI: Move arch specific SRAT parsing vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 22/25] ARM: NUMA: Extract proximity from SRAT table vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 23/25] ARM: NUMA: Initialize ACPI NUMA vijay.kilari
2017-03-28 15:53 ` [RFC PATCH v2 24/25] NUMA: Move CONFIG_NUMA to common Kconfig vijay.kilari
2017-05-31 10:04   ` Jan Beulich
2017-05-31 10:18     ` Julien Grall
2017-05-31 10:37       ` Jan Beulich
2017-06-15  7:52         ` Vijay Kilari
2017-06-15  9:00           ` Julien Grall
2017-03-28 15:53 ` [RFC PATCH v2 25/25] NUMA: Enable ACPI_NUMA config vijay.kilari
2017-05-31 10:05   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490716413-19796-16-git-send-email-vijay.kilari@gmail.com \
    --to=vijay.kilari@gmail.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Vijaya.Kumar@cavium.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.