linux-stable/arch
Siddh Raman Pant 68f0e2aeec x86/numa: Use cpumask_available instead of hardcoded NULL check
[ Upstream commit 625395c4a0 ]

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: c032ef60d1 ("cpumask: convert node_to_cpumask_map[] to cpumask_var_t")
Fixes: de2d9445f1 ("x86: Unify node_to_cpumask_map handling between 32 and 64bit")
Signed-off-by: Siddh Raman Pant <code@siddh.me>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20220731160913.632092-1-code@siddh.me
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-17 14:42:15 +02:00
..
alpha alpha: fix alloc_zeroed_user_highpage_movable() 2022-06-09 10:29:51 +02:00
arc
arm ARM: dts: qcom: msm8974: Disable remoteprocs by default 2022-08-17 14:40:40 +02:00
arm64 KVM: arm64: Don't return from void function 2022-08-17 14:41:44 +02:00
csky csky: patch_text: Fixup last cpu should be master 2022-06-09 10:30:50 +02:00
h8300
hexagon
ia64 ia64: fix typos in comments 2022-08-17 14:40:35 +02:00
m68k m68knommu: fix undefined reference to `mach_get_rtc_pll' 2022-06-14 18:45:03 +02:00
microblaze
mips MIPS: Fixed __debug_virt_addr_valid() 2022-08-17 14:42:06 +02:00
nios2
openrisc openrisc: start CPU timer early in boot 2022-06-09 10:29:44 +02:00
parisc parisc: io_pgetevents_time64() needs compat syscall in 32-bit compat mode 2022-08-17 14:40:09 +02:00
powerpc powerpc/64e: Fix kexec build error 2022-08-17 14:42:15 +02:00
riscv riscv: spinwait: Fix hartid variable type 2022-08-17 14:42:08 +02:00
s390 s390/smp: enforce lowcore protection on CPU restart 2022-08-17 14:42:12 +02:00
sh sh: convert nommu io{re,un}map() to static inline functions 2022-07-22 10:21:22 +02:00
sparc signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:30:00 +02:00
um um: random: Don't initialise hwrng struct with zero 2022-08-17 14:41:49 +02:00
x86 x86/numa: Use cpumask_available instead of hardcoded NULL check 2022-08-17 14:42:15 +02:00
xtensa xtensa: iss: fix handling error cases in iss_net_configure() 2022-08-17 14:41:47 +02:00
.gitignore
Kconfig arch: make TRACE_IRQFLAGS_NMI_SUPPORT generic 2022-08-17 14:40:20 +02:00