[PATCH v2 4/4] x86/cpu/topology: Make cpumask_of_node() robust against NUMA_NO_NODE

John Garry posted 4 patches 1 month ago
[PATCH v2 4/4] x86/cpu/topology: Make cpumask_of_node() robust against NUMA_NO_NODE
Posted by John Garry 1 month ago
The arch definitions of cpumask_of_node() cannot handle NUMA_NO_NODE -
which is a valid index - so add checks for this.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 arch/x86/include/asm/topology.h | 2 ++
 arch/x86/mm/numa.c              | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h
index 1fadf0cf520c5..b51f2e771a582 100644
--- a/arch/x86/include/asm/topology.h
+++ b/arch/x86/include/asm/topology.h
@@ -69,6 +69,8 @@ extern const struct cpumask *cpumask_of_node(int node);
 /* Returns a pointer to the cpumask of CPUs on Node 'node'. */
 static inline const struct cpumask *cpumask_of_node(int node)
 {
+	if (node == NUMA_NO_NODE)
+		return cpu_all_mask;
 	return node_to_cpumask_map[node];
 }
 #endif
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 7a97327140df8..0be94f4682232 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -408,6 +408,8 @@ void numa_remove_cpu(unsigned int cpu)
  */
 const struct cpumask *cpumask_of_node(int node)
 {
+	if (node == NUMA_NO_NODE)
+		return cpu_all_mask;
 	if ((unsigned)node >= nr_node_ids) {
 		printk(KERN_WARNING
 			"cpumask_of_node(%d): (unsigned)node >= nr_node_ids(%u)\n",
-- 
2.43.5