Commit dbce4562 authored by Srikar Dronamraju's avatar Srikar Dronamraju Committed by Michael Ellerman

powerpc/numa: Limit possible nodes to within num_possible_nodes

MAX_NUMNODES is a theoretical maximum number of nodes thats is
supported by the kernel. Device tree properties exposes the number of
possible nodes on the current platform. The kernel would detected this
and would use it for most of its resource allocations. If the platform
now increases the nodes to over what was already exposed, then it may
lead to inconsistencies. Hence limit it to the already exposed nodes.
Suggested-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200724105809.24733-1-srikar@linux.vnet.ibm.com
parent 3327e58a
...@@ -221,7 +221,8 @@ static void initialize_distance_lookup_table(int nid, ...@@ -221,7 +221,8 @@ static void initialize_distance_lookup_table(int nid,
} }
} }
/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa /*
* Returns nid in the range [0..nr_node_ids], or -1 if no useful NUMA
* info is found. * info is found.
*/ */
static int associativity_to_nid(const __be32 *associativity) static int associativity_to_nid(const __be32 *associativity)
...@@ -235,7 +236,7 @@ static int associativity_to_nid(const __be32 *associativity) ...@@ -235,7 +236,7 @@ static int associativity_to_nid(const __be32 *associativity)
nid = of_read_number(&associativity[min_common_depth], 1); nid = of_read_number(&associativity[min_common_depth], 1);
/* POWER4 LPAR uses 0xffff as invalid node */ /* POWER4 LPAR uses 0xffff as invalid node */
if (nid == 0xffff || nid >= MAX_NUMNODES) if (nid == 0xffff || nid >= nr_node_ids)
nid = NUMA_NO_NODE; nid = NUMA_NO_NODE;
if (nid > 0 && if (nid > 0 &&
...@@ -448,7 +449,7 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb) ...@@ -448,7 +449,7 @@ static int of_drconf_to_nid_single(struct drmem_lmb *lmb)
index = lmb->aa_index * aa.array_sz + min_common_depth - 1; index = lmb->aa_index * aa.array_sz + min_common_depth - 1;
nid = of_read_number(&aa.arrays[index], 1); nid = of_read_number(&aa.arrays[index], 1);
if (nid == 0xffff || nid >= MAX_NUMNODES) if (nid == 0xffff || nid >= nr_node_ids)
nid = default_nid; nid = default_nid;
if (nid > 0) { if (nid > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment