Michal Suchanek 85cd26
From dbce456280857f329af9069af5e48a9b6ebad146 Mon Sep 17 00:00:00 2001
Michal Suchanek 85cd26
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Michal Suchanek 85cd26
Date: Fri, 24 Jul 2020 16:28:09 +0530
Michal Suchanek 85cd26
Subject: [PATCH] powerpc/numa: Limit possible nodes to within
Michal Suchanek 85cd26
 num_possible_nodes
Michal Suchanek 85cd26
Michal Suchanek 85cd26
References: bsc#1209999 ltc#202140 bsc#1142685 ltc#179509 FATE#327775 git-fixes
Michal Suchanek 85cd26
Patch-mainline: v5.9-rc1
Michal Suchanek 85cd26
Git-commit: dbce456280857f329af9069af5e48a9b6ebad146
Michal Suchanek 85cd26
Michal Suchanek 85cd26
MAX_NUMNODES is a theoretical maximum number of nodes thats is
Michal Suchanek 85cd26
supported by the kernel. Device tree properties exposes the number of
Michal Suchanek 85cd26
possible nodes on the current platform. The kernel would detected this
Michal Suchanek 85cd26
and would use it for most of its resource allocations. If the platform
Michal Suchanek 85cd26
now increases the nodes to over what was already exposed, then it may
Michal Suchanek 85cd26
lead to inconsistencies. Hence limit it to the already exposed nodes.
Michal Suchanek 85cd26
Michal Suchanek 85cd26
Suggested-by: Nathan Lynch <nathanl@linux.ibm.com>
Michal Suchanek 85cd26
Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Michal Suchanek 85cd26
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Michal Suchanek 85cd26
Link: https://lore.kernel.org/r/20200724105809.24733-1-srikar@linux.vnet.ibm.com
Michal Suchanek 85cd26
Acked-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek 85cd26
---
Michal Suchanek 85cd26
 arch/powerpc/mm/numa.c | 7 ++++---
Michal Suchanek 85cd26
 1 file changed, 4 insertions(+), 3 deletions(-)
Michal Suchanek 85cd26
Michal Suchanek 85cd26
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
Michal Suchanek 85cd26
index e437a9ac4956..92938393fec6 100644
Michal Suchanek 85cd26
--- a/arch/powerpc/mm/numa.c
Michal Suchanek 85cd26
+++ b/arch/powerpc/mm/numa.c
Michal Suchanek 85cd26
@@ -221,7 +221,8 @@ static void initialize_distance_lookup_table(int nid,
Michal Suchanek 85cd26
 	}
Michal Suchanek 85cd26
 }
Michal Suchanek 85cd26
 
Michal Suchanek 85cd26
-/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
Michal Suchanek 85cd26
+/*
Michal Suchanek 85cd26
+ * Returns nid in the range [0..nr_node_ids], or -1 if no useful NUMA
Michal Suchanek 85cd26
  * info is found.
Michal Suchanek 85cd26
  */
Michal Suchanek 85cd26
 static int associativity_to_nid(const __be32 *associativity)
Michal Suchanek 85cd26
@@ -235,7 +236,7 @@ static int associativity_to_nid(const __be32 *associativity)
Michal Suchanek 85cd26
 		nid = of_read_number(&associativity[min_common_depth], 1);
Michal Suchanek 85cd26
 
Michal Suchanek 85cd26
 	/* POWER4 LPAR uses 0xffff as invalid node */
Michal Suchanek 85cd26
-	if (nid == 0xffff || nid >= MAX_NUMNODES)
Michal Suchanek 85cd26
+	if (nid == 0xffff || nid >= nr_node_ids)
Michal Suchanek 85cd26
 		nid = NUMA_NO_NODE;
Michal Suchanek 85cd26
 
Michal Suchanek 85cd26
 	if (nid > 0 &&
Michal Suchanek 85cd26
@@ -448,7 +449,7 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
Michal Suchanek 85cd26
 		index = lmb->aa_index * aa.array_sz + min_common_depth - 1;
Michal Suchanek 85cd26
 		nid = of_read_number(&aa.arrays[index], 1);
Michal Suchanek 85cd26
 
Michal Suchanek 85cd26
-		if (nid == 0xffff || nid >= MAX_NUMNODES)
Michal Suchanek 85cd26
+		if (nid == 0xffff || nid >= nr_node_ids)
Michal Suchanek 85cd26
 			nid = default_nid;
Michal Suchanek 85cd26
 
Michal Suchanek 85cd26
 		if (nid > 0) {
Michal Suchanek 85cd26
-- 
Michal Suchanek 85cd26
2.40.0
Michal Suchanek 85cd26