From 08d0f05498e5c0729f141615659bec8200cde901 Mon Sep 17 00:00:00 2001 From: Kemeng Shi Date: Wed, 21 Jul 2021 17:43:06 +0800 Subject: [PATCH] acpi/numa: memorize pmem node from SRAT table euleros inclusion category: feature feature: etmem bugzilla: 48246 ------------------------------------------------- Driver dax_kmem will export pmem as a NUMA node. This patch will record node consists of persistent memory for futher use. Signed-off-by: Kemeng Shi Reviewed-by: louhongxiang --- drivers/acpi/numa/srat.c | 3 +++ include/linux/numa.h | 3 +++ mm/page_alloc.c | 12 ++++++++++++ 3 files changed, 18 insertions(+) diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 6021a1013442..1eff5ad56701 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -279,6 +279,9 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) node_set(node, numa_nodes_parsed); + if (ma->flags & ACPI_SRAT_MEM_NON_VOLATILE) + set_node_pmem(node); + pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s%s\n", node, pxm, (unsigned long long) start, (unsigned long long) end - 1, diff --git a/include/linux/numa.h b/include/linux/numa.h index cb44cfe2b725..3539b8609f60 100644 --- a/include/linux/numa.h +++ b/include/linux/numa.h @@ -58,4 +58,7 @@ static inline int phys_to_target_node(u64 start) } #endif +void set_node_pmem(int nid); +int is_node_pmem(int nid); + #endif /* _LINUX_NUMA_H */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 91be63abbd7a..0cba3f02eb3c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -179,6 +179,8 @@ DEFINE_STATIC_KEY_FALSE(init_on_free); #endif EXPORT_SYMBOL(init_on_free); +nodemask_t numa_nodes_pmem; + static int __init early_init_on_alloc(char *buf) { int ret; @@ -8882,3 +8884,13 @@ bool take_page_off_buddy(struct page *page) return ret; } #endif + +void set_node_pmem(int nid) +{ + node_set(nid, numa_nodes_pmem); +} + +int is_node_pmem(int nid) +{ + return node_isset(nid, numa_nodes_pmem); +} -- GitLab