|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 04/21] xen/arm: Configure NUMA affinity for populated memory banks
Configure NUMA affinity for the populated memory banks. The NUMA
node ID for each memory bank is retrieved from the Device Tree.
---
xen/arch/arm/include/asm/numa.h | 1 +
xen/arch/arm/numa.c | 7 +++++++
xen/arch/arm/setup.c | 2 +-
xen/common/device-tree/bootinfo-fdt.c | 8 ++++++++
xen/common/device-tree/numa.c | 29 +++++++++++++++++++++++++++
xen/include/xen/bootinfo.h | 23 +++++++++++++++++++++
xen/include/xen/dt-numa.h | 1 +
7 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/include/asm/numa.h b/xen/arch/arm/include/asm/numa.h
index a1fa54f2e7..6f1ccb4eb3 100644
--- a/xen/arch/arm/include/asm/numa.h
+++ b/xen/arch/arm/include/asm/numa.h
@@ -12,6 +12,7 @@ typedef u8 nodeid_t;
extern bool numa_disabled(void);
extern unsigned int numa_node_to_arch_nid(nodeid_t n);
extern u8 __node_distance(nodeid_t a, nodeid_t b);
+extern void numa_memory_affinity_init(void);
#define arch_want_default_dmazone() (num_online_nodes() > 1)
diff --git a/xen/arch/arm/numa.c b/xen/arch/arm/numa.c
index 080d7892ae..15cad3d267 100644
--- a/xen/arch/arm/numa.c
+++ b/xen/arch/arm/numa.c
@@ -36,6 +36,13 @@ int __init arch_numa_setup(const char *opt)
return 0;
}
+void __init numa_memory_affinity_init(void)
+{
+ dt_numa_memory_affinity_init();
+
+ numa_initmem_init(0x0UL, 0x1UL << (PADDR_BITS - 12));
+}
+
int __init arch_get_ram_range(unsigned int idx, paddr_t *start, paddr_t *end)
{
return bootinfo_get_ram_range(idx, start, end);
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index c0202d9ff6..cdabf536b0 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -352,7 +352,7 @@ void asmlinkage __init noreturn start_xen(unsigned long
fdt_paddr)
acpi_boot_table_init();
#ifdef CONFIG_NUMA
- numa_initmem_init(0x0UL, 0x1UL << (PADDR_BITS - 12));
+ numa_memory_affinity_init();
#endif /* CONFIG_NUMA */
end_boot_allocator();
diff --git a/xen/common/device-tree/bootinfo-fdt.c
b/xen/common/device-tree/bootinfo-fdt.c
index 272b5a6c0a..2d0e809231 100644
--- a/xen/common/device-tree/bootinfo-fdt.c
+++ b/xen/common/device-tree/bootinfo-fdt.c
@@ -121,6 +121,9 @@ static int __init device_tree_get_meminfo(const void *fdt,
int node,
const __be32 *cell;
u32 reg_cells = address_cells + size_cells;
paddr_t start, size;
+#ifdef CONFIG_DEVICE_TREE_NUMA
+ uint32_t nid;
+#endif /* CONFIG_DEVICE_TREE_NUMA */
if ( !device_tree_node_is_available(fdt, node) )
return 0;
@@ -136,6 +139,10 @@ static int __init device_tree_get_meminfo(const void *fdt,
int node,
if ( !prop )
return -ENOENT;
+#ifdef CONFIG_DEVICE_TREE_NUMA
+ nid = device_tree_get_u32(fdt, node, "numa-node-id", 0U);
+#endif /* CONFIG_DEVICE_TREE_NUMA */
+
cell = (const __be32 *)prop->data;
banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32));
@@ -158,6 +165,7 @@ static int __init device_tree_get_meminfo(const void *fdt,
int node,
mem->bank[mem->nr_banks].start = start;
mem->bank[mem->nr_banks].size = size;
mem->bank[mem->nr_banks].type = type;
+ set_numa_nodeid(&mem->bank[mem->nr_banks], nid);
mem->nr_banks++;
}
diff --git a/xen/common/device-tree/numa.c b/xen/common/device-tree/numa.c
index 06f2c8b102..539ddfccc5 100644
--- a/xen/common/device-tree/numa.c
+++ b/xen/common/device-tree/numa.c
@@ -22,3 +22,32 @@ u8 dt_node_distance(u8 a, u8 b)
return LOCAL_DISTANCE;
}
+/*
+ * Initialize memory affinity by registering bootinfo memory banks into Xen's
+ * NUMA subsystem.
+ */
+void __init dt_numa_memory_affinity_init(void)
+{
+ const struct membanks *mem = bootinfo_get_mem();
+ unsigned int bank;
+ nodeid_t nid;
+
+ numa_fw_nid_name = "DT";
+
+ for ( bank = 0 ; bank < mem->nr_banks; bank++ )
+ {
+ nid = get_numa_nodeid(&mem->bank[bank]);
+
+ if (numa_memblks_available())
+ {
+ numa_update_node_memblks(nid, nid, mem->bank[bank].start,
mem->bank[bank].size, false);
+ }
+ else
+ {
+ dprintk(XENLOG_WARNING,
+ "Too many numa entries, try bigger NR_NODE_MEMBLKS!\n");
+ numa_fw_bad();
+ break;
+ }
+ }
+}
diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h
index 7923be2b38..d01a28b359 100644
--- a/xen/include/xen/bootinfo.h
+++ b/xen/include/xen/bootinfo.h
@@ -7,6 +7,7 @@
#include <xen/macros.h>
#include <xen/xmalloc.h>
#include <xen/errno.h>
+#include <xen/numa.h>
#define NR_MEM_BANKS 256
#define NR_SHMEM_BANKS 32
@@ -56,6 +57,9 @@ struct shmem_membank_extra {
struct membank {
paddr_t start;
paddr_t size;
+#ifdef CONFIG_DEVICE_TREE_NUMA
+ uint32_t numa_id;
+#endif /* CONFIG_DEVICE_TREE_NUMA */
union {
enum membank_type type;
#ifdef CONFIG_STATIC_SHM
@@ -228,4 +232,23 @@ static inline int bootinfo_get_ram_range(unsigned int idx,
paddr_t *start, paddr
return 0;
}
+#ifdef CONFIG_DEVICE_TREE_NUMA
+static inline uint32_t get_numa_nodeid(const struct membank *bank)
+{
+ if ( numa_disabled() ) return 0U;
+
+ return bank->numa_id;
+}
+
+static inline void set_numa_nodeid(struct membank *bank, uint32_t nid)
+{
+ if ( numa_disabled() ) nid = 0U;
+
+ bank->numa_id = nid;
+}
+#else /* CONFIG_DEVICE_TREE_NUMA */
+#define get_numa_nodeid(bank) (0)
+#define set_numa_nodeid(bank, nid) {}
+#endif /* CONFIG_DEVICE_TREE_NUMA */
+
#endif /* XEN_BOOTINFO_H */
diff --git a/xen/include/xen/dt-numa.h b/xen/include/xen/dt-numa.h
index 721e8955fa..c6939d0928 100644
--- a/xen/include/xen/dt-numa.h
+++ b/xen/include/xen/dt-numa.h
@@ -14,6 +14,7 @@ static inline unsigned int numa_node_to_dt_nid(u32 n)
#ifdef CONFIG_DEVICE_TREE_NUMA
u8 dt_node_distance(u8 a, u8 b);
+void dt_numa_memory_affinity_init(void);
#endif /* CONFIG_DEVICE_TREE_NUMA */
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |