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 16/25] ARM: NUMA: Add memory NUMA support
Date: Tue, 28 Mar 2017 21:23:24 +0530	[thread overview]
Message-ID: <1490716413-19796-17-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>

Implement arch_sanitize_nodes_memory() which looks at all banks
in bootinfo.mem, update nodes[] with corresponding nodeid.
Call numa_scan_nodes() generic function with ram start and
end address, which takes care of further computing memnodeshift
and populating memnodemap[] using generic implementation.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
---
 xen/arch/arm/numa/numa.c   | 79 +++++++++++++++++++++++++++++++++++++++++++++-
 xen/common/numa.c          | 14 ++++++++
 xen/include/asm-arm/numa.h | 19 +++++++++++
 xen/include/xen/numa.h     |  1 +
 4 files changed, 112 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/numa/numa.c b/xen/arch/arm/numa/numa.c
index eef5870..7583a40 100644
--- a/xen/arch/arm/numa/numa.c
+++ b/xen/arch/arm/numa/numa.c
@@ -70,9 +70,74 @@ void numa_failed(void)
     init_cpu_to_node();
 }
 
+int __init arch_sanitize_nodes_memory(void)
+{
+    nodemask_t mem_nodes_parsed;
+    int bank, nodeid;
+    struct node *nd;
+    paddr_t start, size, end;
+
+    nodes_clear(mem_nodes_parsed);
+    for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ )
+    {
+        start = bootinfo.mem.bank[bank].start;
+        size = bootinfo.mem.bank[bank].size;
+        end = start + size;
+
+        nodeid = get_mem_nodeid(start, end);
+        if ( nodeid >= NUMA_NO_NODE )
+        {
+            printk(XENLOG_WARNING
+                   "NUMA: node for mem bank start 0x%lx - 0x%lx not found\n",
+                   start, end);
+
+            return 0;
+        }
+
+        nd = get_numa_node(nodeid);
+        if ( !node_test_and_set(nodeid, mem_nodes_parsed) )
+        {
+            nd->start = start;
+            nd->end = end;
+        }
+        else
+        {
+            if ( start < nd->start )
+                nd->start = start;
+            if ( nd->end < end )
+                nd->end = end;
+        }
+    }
+
+    return 1;
+}
+
+static bool_t __init numa_initmem_init(paddr_t ram_start, paddr_t ram_end)
+{
+    int i;
+    struct node *nd;
+    /*
+     * In arch_sanitize_nodes_memory() we update nodes[] with properly.
+     * Hence we reset the nodes[] before calling numa_scan_nodes().
+     */
+    for ( i = 0; i < MAX_NUMNODES; i++ )
+    {
+        nd = get_numa_node(i);
+        nd->start = 0;
+        nd->end = 0;
+    }
+
+    if ( !numa_scan_nodes(ram_start, ram_end) )
+            return 0;
+
+    return 1;
+}
+
 void __init numa_init(void)
 {
-    int ret = 0;
+    int ret = 0, bank;
+    paddr_t ram_start = ~0;
+    paddr_t ram_end = 0;
 
     nodes_clear(processor_nodes_parsed);
     init_cpu_to_node();
@@ -87,6 +152,18 @@ void __init numa_init(void)
     if ( ret )
         printk(XENLOG_WARNING "DT NUMA init failed\n");
 
+    for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ )
+    {
+        paddr_t bank_start = bootinfo.mem.bank[bank].start;
+        paddr_t bank_end = bank_start + bootinfo.mem.bank[bank].size;
+
+        ram_start = min(ram_start, bank_start);
+        ram_end = max(ram_end, bank_end);
+    }
+
+    if ( !ret )
+        ret = numa_initmem_init(ram_start, ram_end);
+
 no_numa:
     return;
 }
diff --git a/xen/common/numa.c b/xen/common/numa.c
index 1789bba..f2ac726 100644
--- a/xen/common/numa.c
+++ b/xen/common/numa.c
@@ -84,6 +84,20 @@ nodeid_t get_memblk_nodeid(int id)
     return memblk_nodeid[id];
 }
 
+int __init get_mem_nodeid(paddr_t start, paddr_t end)
+{
+    unsigned int i;
+
+    for ( i = 0; i < get_num_node_memblks(); i++ )
+    {
+        if ( start >= node_memblk_range[i].start &&
+             end <= node_memblk_range[i].end )
+            return memblk_nodeid[i];
+    }
+
+    return -EINVAL;
+}
+
 nodeid_t *get_memblk_nodeid_map(void)
 {
     return &memblk_nodeid[0];
diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h
index 65bdd5e..85fbbe8 100644
--- a/xen/include/asm-arm/numa.h
+++ b/xen/include/asm-arm/numa.h
@@ -1,6 +1,8 @@
 #ifndef __ARCH_ARM_NUMA_H
 #define __ARCH_ARM_NUMA_H
 
+#include <xen/mm.h>
+
 typedef uint8_t nodeid_t;
 
 /* Limit number of NUMA nodes supported to 4 */
@@ -28,6 +30,23 @@ extern uint8_t *memnodemap;
 #define node_to_first_cpu(node)  (__ffs(node_to_cpumask[node]))
 #define node_to_cpumask(node)    (node_to_cpumask[node])
 
+static inline __attribute__((pure)) nodeid_t phys_to_nid(paddr_t addr)
+{
+    return memnodemap[paddr_to_pdx(addr) >> memnode_shift];
+}
+
+struct node_data {
+    unsigned long node_start_pfn;
+    unsigned long node_spanned_pages;
+};
+
+extern struct node_data node_data[];
+#define NODE_DATA(nid)          (&(node_data[nid]))
+
+#define node_start_pfn(nid)     (NODE_DATA(nid)->node_start_pfn)
+#define node_spanned_pages(nid) (NODE_DATA(nid)->node_spanned_pages)
+#define node_end_pfn(nid)       (NODE_DATA(nid)->node_start_pfn + \
+
 #else
 static inline void numa_init(void)
 {
diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
index ee53526..b40a841 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -38,6 +38,7 @@ extern nodeid_t *get_memblk_nodeid_map(void);
 extern struct node *get_node_memblk_range(int memblk);
 extern struct node *get_memblk(int memblk);
 extern int numa_add_memblk(nodeid_t nodeid, paddr_t start, uint64_t size);
+extern int get_mem_nodeid(paddr_t start, paddr_t end);
 extern int get_num_node_memblks(void);
 extern int arch_sanitize_nodes_memory(void);
 extern void numa_failed(void);
-- 
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 ` [RFC PATCH v2 15/25] ARM: NUMA: Add CPU NUMA support vijay.kilari
2017-03-28 15:53 ` vijay.kilari [this message]
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-17-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.