include/asm-generic/percpu.h:21:44: warning: array subscript 32 is above array bounds of 'long unsigned int[32]'

From: kernel test robot

Date: Mon Sep 22 2025 - 09:33:38 EST


Hi Yury,

FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 07e27ad16399afcd693be20211b0dfae63e0615f
commit: fda1dd3c54ef3c4200c2e77634a91610da973950 find: Switch from inline to __always_inline
date: 1 year, 1 month ago
config: riscv-randconfig-r111-20250922 (https://download.01.org/0day-ci/archive/20250922/202509222148.aujDHbuM-lkp@xxxxxxxxx/config)
compiler: riscv32-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250922/202509222148.aujDHbuM-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509222148.aujDHbuM-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from include/linux/compiler_types.h:174,
from <command-line>:
drivers/base/test/test_async_driver_probe.c: In function 'test_async_probe_init':
>> include/asm-generic/percpu.h:21:44: warning: array subscript 32 is above array bounds of 'long unsigned int[32]' [-Warray-bounds]
#define per_cpu_offset(x) (__per_cpu_offset[x])
include/linux/compiler-gcc.h:35:26: note: in definition of macro 'RELOC_HIDE'
(typeof(ptr)) (__ptr + (off)); \
^~~
include/linux/percpu-defs.h:236:2: note: in expansion of macro 'SHIFT_PERCPU_PTR'
SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))); \
^~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:236:26: note: in expansion of macro 'per_cpu_offset'
SHIFT_PERCPU_PTR((ptr), per_cpu_offset((cpu))); \
^~~~~~~~~~~~~~
include/linux/percpu-defs.h:269:29: note: in expansion of macro 'per_cpu_ptr'
#define per_cpu(var, cpu) (*per_cpu_ptr(&(var), cpu))
^~~~~~~~~~~
include/linux/topology.h:96:9: note: in expansion of macro 'per_cpu'
return per_cpu(numa_node, cpu);
^~~~~~~


vim +21 include/asm-generic/percpu.h

^1da177e4c3f41 Linus Torvalds 2005-04-16 20
a875a69f8b00a3 Ingo Molnar 2006-07-03 @21 #define per_cpu_offset(x) (__per_cpu_offset[x])
acdac87202a408 travis@xxxxxxx 2008-01-30 22 #endif
acdac87202a408 travis@xxxxxxx 2008-01-30 23

:::::: The code at line 21 was first introduced by commit
:::::: a875a69f8b00a38b4f40d9632a4fc71a159f0e0d [PATCH] lockdep: add per_cpu_offset()

:::::: TO: Ingo Molnar <mingo@xxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki