[PATCH 1/2] mm/numa_emulation: Refactor NUMA emulation size handling to use kernel macros

pratyush.brahma@oss.qualcomm.com posted 2 patches 5 days, 11 hours ago
There is a newer version of this series
[PATCH 1/2] mm/numa_emulation: Refactor NUMA emulation size handling to use kernel macros
Posted by pratyush.brahma@oss.qualcomm.com 5 days, 11 hours ago
From: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>

Replace hard‑coded 32 MB constant with SZ_32M and apply ALIGN_DOWN for
clearer calculations and maintainability.  Update the related hash mask
usage accordingly to improve readability.

Signed-off-by: Pratyush Brahma <pratyush.brahma@oss.qualcomm.com>
---
 mm/numa_emulation.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c
index 703c8fa05048..2a335b3dd46a 100644
--- a/mm/numa_emulation.c
+++ b/mm/numa_emulation.c
@@ -10,8 +10,7 @@
 #include <asm/numa.h>
 #include <acpi/acpi_numa.h>
 
-#define FAKE_NODE_MIN_SIZE	((u64)32 << 20)
-#define FAKE_NODE_MIN_HASH_MASK	(~(FAKE_NODE_MIN_SIZE - 1UL))
+#define FAKE_NODE_MIN_SIZE	SZ_32M
 
 int emu_nid_to_phys[MAX_NUMNODES];
 static char *emu_cmdline __initdata;
@@ -112,10 +111,10 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei,
 	 * Calculate the number of big nodes that can be allocated as a result
 	 * of consolidating the remainder.
 	 */
-	big = ((size & ~FAKE_NODE_MIN_HASH_MASK) * nr_nodes) /
+	big = ((size & (FAKE_NODE_MIN_SIZE - 1UL)) * nr_nodes) /
 		FAKE_NODE_MIN_SIZE;
 
-	size &= FAKE_NODE_MIN_HASH_MASK;
+	size = ALIGN_DOWN(size, FAKE_NODE_MIN_SIZE);
 	if (!size) {
 		pr_err("Not enough memory for each node.  "
 			"NUMA emulation disabled.\n");

-- 
2.34.1