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 12/25] ARM: NUMA: Parse CPU NUMA information
Date: Tue, 28 Mar 2017 21:23:20 +0530 [thread overview]
Message-ID: <1490716413-19796-13-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>
Parse CPU node and fetch numa-node-id information.
For each node-id found, update nodemask_t mask.
Refer to /Documentation/devicetree/bindings/numa.txt.
Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
---
xen/arch/arm/Makefile | 1 +
xen/arch/arm/bootfdt.c | 16 ++++++++--
xen/arch/arm/numa/Makefile | 2 ++
xen/arch/arm/numa/dt_numa.c | 78 +++++++++++++++++++++++++++++++++++++++++++++
xen/arch/arm/numa/numa.c | 50 +++++++++++++++++++++++++++++
xen/arch/arm/setup.c | 4 +++
xen/include/asm-arm/numa.h | 10 +++++-
xen/include/asm-arm/setup.h | 4 ++-
8 files changed, 161 insertions(+), 4 deletions(-)
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 0ce94a8..d13b79f 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -3,6 +3,7 @@ subdir-$(CONFIG_ARM_64) += arm64
subdir-y += platforms
subdir-$(CONFIG_ARM_64) += efi
subdir-$(CONFIG_ACPI) += acpi
+subdir-$(CONFIG_NUMA) += numa
obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o
obj-y += bootfdt.init.o
diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index ea188a0..1f876f0 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -62,8 +62,20 @@ static void __init device_tree_get_reg(const __be32 **cell, u32 address_cells,
*size = dt_next_cell(size_cells, cell);
}
-static u32 __init device_tree_get_u32(const void *fdt, int node,
- const char *prop_name, u32 dflt)
+bool_t __init device_tree_type_matches(const void *fdt, int node,
+ const char *match)
+{
+ const void *prop;
+
+ prop = fdt_getprop(fdt, node, "device_type", NULL);
+ if ( prop == NULL )
+ return 0;
+
+ return strcmp(prop, match) == 0 ? 1 : 0;
+}
+
+u32 __init device_tree_get_u32(const void *fdt, int node,
+ const char *prop_name, u32 dflt)
{
const struct fdt_property *prop;
diff --git a/xen/arch/arm/numa/Makefile b/xen/arch/arm/numa/Makefile
new file mode 100644
index 0000000..3af3aff
--- /dev/null
+++ b/xen/arch/arm/numa/Makefile
@@ -0,0 +1,2 @@
+obj-y += dt_numa.o
+obj-y += numa.o
diff --git a/xen/arch/arm/numa/dt_numa.c b/xen/arch/arm/numa/dt_numa.c
new file mode 100644
index 0000000..66c6efb
--- /dev/null
+++ b/xen/arch/arm/numa/dt_numa.c
@@ -0,0 +1,78 @@
+/*
+ * OF NUMA Parsing support.
+ *
+ * Copyright (C) 2015 - 2016 Cavium Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/libfdt/libfdt.h>
+#include <xen/mm.h>
+#include <xen/nodemask.h>
+#include <asm/mm.h>
+#include <xen/numa.h>
+#include <xen/device_tree.h>
+#include <asm/setup.h>
+
+extern nodemask_t processor_nodes_parsed;
+
+/*
+ * Even though we connect cpus to numa domains later in SMP
+ * init, we need to know the node ids now for all cpus.
+ */
+static int __init dt_numa_process_cpu_node(const void *fdt, int node,
+ const char *name,
+ uint32_t address_cells,
+ uint32_t size_cells)
+{
+ uint32_t nid;
+
+ nid = device_tree_get_u32(fdt, node, "numa-node-id", MAX_NUMNODES);
+
+ if ( nid >= MAX_NUMNODES )
+ printk(XENLOG_WARNING "NUMA: Node id %u exceeds maximum value\n", nid);
+ else
+ node_set(nid, processor_nodes_parsed);
+
+ return 0;
+}
+
+static int __init dt_numa_scan_cpu_node(const void *fdt, int node,
+ const char *name, int depth,
+ uint32_t address_cells,
+ uint32_t size_cells, void *data)
+{
+ if ( device_tree_type_matches(fdt, node, "cpu") )
+ return dt_numa_process_cpu_node(fdt, node, name, address_cells,
+ size_cells);
+
+ return 0;
+}
+
+int __init dt_numa_init(void)
+{
+ int ret;
+
+ ret = device_tree_for_each_node((void *)device_tree_flattened,
+ dt_numa_scan_cpu_node, NULL);
+ return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/numa/numa.c b/xen/arch/arm/numa/numa.c
new file mode 100644
index 0000000..c1c7c35
--- /dev/null
+++ b/xen/arch/arm/numa/numa.c
@@ -0,0 +1,50 @@
+/*
+ * ARM NUMA Implementation
+ *
+ * Copyright (C) 2016 - Cavium Inc.
+ * Vijaya Kumar K <vijaya.kumar@cavium.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <xen/init.h>
+#include <xen/ctype.h>
+#include <xen/mm.h>
+#include <xen/nodemask.h>
+#include <asm/mm.h>
+#include <xen/numa.h>
+#include <asm/acpi.h>
+
+extern nodemask_t processor_nodes_parsed;
+
+void __init numa_init(void)
+{
+ int ret = 0;
+
+ nodes_clear(processor_nodes_parsed);
+ if ( is_numa_off() )
+ goto no_numa;
+
+ ret = dt_numa_init();
+ if ( ret )
+ printk(XENLOG_WARNING "DT NUMA init failed\n");
+
+no_numa:
+ return;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 92a2de6..ed58f0e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -38,6 +38,7 @@
#include <xen/libfdt/libfdt.h>
#include <xen/acpi.h>
#include <asm/alternative.h>
+#include <xen/numa.h>
#include <asm/page.h>
#include <asm/current.h>
#include <asm/setup.h>
@@ -758,6 +759,9 @@ void __init start_xen(unsigned long boot_phys_offset,
else
printk("Booting using ACPI\n");
+ /* numa_init parses acpi tables. So call after acpi init */
+ numa_init();
+
end_boot_allocator();
vm_init();
diff --git a/xen/include/asm-arm/numa.h b/xen/include/asm-arm/numa.h
index 924bfc0..e50ee19 100644
--- a/xen/include/asm-arm/numa.h
+++ b/xen/include/asm-arm/numa.h
@@ -6,7 +6,15 @@ typedef uint8_t nodeid_t;
/* Limit number of NUMA nodes supported to 4 */
#define NODES_SHIFT 2
-#ifndef CONFIG_NUMA
+#ifdef CONFIG_NUMA
+extern void numa_init(void);
+extern int dt_numa_init(void);
+#else
+static inline void numa_init(void)
+{
+ 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)
diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
index 7c76185..b1022a3 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -79,7 +79,9 @@ struct bootmodule *add_boot_module(bootmodule_kind kind,
const char *cmdline);
struct bootmodule *boot_module_find_by_kind(bootmodule_kind kind);
const char * __init boot_module_kind_as_string(bootmodule_kind kind);
-
+u32 device_tree_get_u32(const void *fdt, int node,
+ const char *prop_name, u32 dflt);
+bool_t device_tree_type_matches(const void *fdt, int node, const char *match);
#endif
/*
* Local variables:
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev 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 ` vijay.kilari [this message]
2017-05-08 17:31 ` [RFC PATCH v2 12/25] ARM: NUMA: Parse CPU NUMA information 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 ` [RFC PATCH v2 16/25] ARM: NUMA: Add memory " 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-13-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).