Skip to content

Commit 625395c

Browse files
siddhpantIngo Molnar
authored andcommitted
x86/numa: Use cpumask_available instead of hardcoded NULL check
GCC-12 started triggering a new warning: arch/x86/mm/numa.c: In function ‘cpumask_of_node’: arch/x86/mm/numa.c:916:39: warning: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Waddress] 916 | if (node_to_cpumask_map[node] == NULL) { | ^~ node_to_cpumask_map is of type cpumask_var_t[]. When CONFIG_CPUMASK_OFFSTACK is set, cpumask_var_t is typedef'd to a pointer for dynamic allocation, else to an array of one element. The "wicked game" can be checked on line 700 of include/linux/cpumask.h. The original code in debug_cpumask_set_cpu() and cpumask_of_node() were probably written by the original authors with CONFIG_CPUMASK_OFFSTACK=y (i.e. dynamic allocation) in mind, checking if the cpumask was available via a direct NULL check. When CONFIG_CPUMASK_OFFSTACK is not set, GCC gives the above warning while compiling the kernel. Fix that by using cpumask_available(), which does the NULL check when CONFIG_CPUMASK_OFFSTACK is set, otherwise returns true. Use it wherever such checks are made. Conditional definitions of cpumask_available() can be found along with the definition of cpumask_var_t. Check the cpumask.h reference mentioned above. Fixes: c032ef6 ("cpumask: convert node_to_cpumask_map[] to cpumask_var_t") Fixes: de2d944 ("x86: Unify node_to_cpumask_map handling between 32 and 64bit") Signed-off-by: Siddh Raman Pant <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ffa6482 commit 625395c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/mm/numa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)
867867
return;
868868
}
869869
mask = node_to_cpumask_map[node];
870-
if (!mask) {
870+
if (!cpumask_available(mask)) {
871871
pr_err("node_to_cpumask_map[%i] NULL\n", node);
872872
dump_stack();
873873
return;
@@ -913,7 +913,7 @@ const struct cpumask *cpumask_of_node(int node)
913913
dump_stack();
914914
return cpu_none_mask;
915915
}
916-
if (node_to_cpumask_map[node] == NULL) {
916+
if (!cpumask_available(node_to_cpumask_map[node])) {
917917
printk(KERN_WARNING
918918
"cpumask_of_node(%d): no node_to_cpumask_map!\n",
919919
node);

0 commit comments

Comments
 (0)