[PATCH] x86/numa: Bump NR_NODE_MEMBLKS to MAX_NUMNODES * 4

From: Nikolay Kuratov
Date: Mon May 20 2024 - 10:56:30 EST


With modern AMD EPYC platform we're able to spot 3
memblocks per NUMA, so bump MAX_NUMNODES multiplier
from 2 to 4. Problem becomes apparent if MAX_NUMNODES
close enough to real amount of nodes and leaves us with
`too many memblk ranges` dmesg error.

Bump also maximal count of immovable regions accordingly.

Signed-off-by: Nikolay Kuratov <kniv@xxxxxxxxxxxxxx>
---
If overhead related to doubled arrays is too undesirable
maybe we should consider config option for this? It appears that
NR_NODE_MEMBLKS used only on LoongArch and x86 (macro in asm-generic
is orphane).

arch/x86/boot/compressed/acpi.c | 6 +++---
arch/x86/boot/compressed/misc.h | 2 +-
arch/x86/include/asm/numa.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index f196b1d1ddf8..74575a900924 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -17,9 +17,9 @@

/*
* Immovable memory regions representation. Max amount of memory regions is
- * MAX_NUMNODES*2.
+ * MAX_NUMNODES*4.
*/
-struct mem_vector immovable_mem[MAX_NUMNODES*2];
+struct mem_vector immovable_mem[MAX_NUMNODES*4];

static acpi_physical_address
__efi_get_rsdp_addr(unsigned long cfg_tbl_pa, unsigned int cfg_tbl_len)
@@ -305,7 +305,7 @@ int count_immovable_mem_regions(void)
num++;
}

- if (num >= MAX_NUMNODES*2) {
+ if (num >= ARRAY_SIZE(immovable_mem)) {
debug_putstr("Too many immovable memory regions, aborting.\n");
return 0;
}
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index b353a7be380c..a756569852e5 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -174,7 +174,7 @@ static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
#endif

#if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
-extern struct mem_vector immovable_mem[MAX_NUMNODES*2];
+extern struct mem_vector immovable_mem[MAX_NUMNODES*4];
int count_immovable_mem_regions(void);
#else
static inline int count_immovable_mem_regions(void) { return 0; }
diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h
index ef2844d69173..057eafe6fed5 100644
--- a/arch/x86/include/asm/numa.h
+++ b/arch/x86/include/asm/numa.h
@@ -10,7 +10,7 @@

#ifdef CONFIG_NUMA

-#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
+#define NR_NODE_MEMBLKS (MAX_NUMNODES*4)

extern int numa_off;

--
2.34.1