include/linux/vmstat.h:400:43: error: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item')

From: kernel test robot
Date: Sat Mar 02 2024 - 23:19:19 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 04b8076df2534f08bb4190f90a24e0f7f8930aca
commit: c348c16305280fe3e6c1186378f96c8634c149f9 lib: make a test module with set/clear bit
date: 3 years, 9 months ago
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20240303/202403031232.DGh2J4ks-lkp@xxxxxxxxx/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 325f51237252e6dab8e4e1ea1fa7acbb4faee1cd)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240303/202403031232.DGh2J4ks-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/202403031232.DGh2J4ks-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

In file included from lib/test_bitops.c:9:
In file included from include/linux/module.h:18:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:145:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:1485:
>> include/linux/vmstat.h:400:43: error: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Werror,-Wenum-enum-conversion]
400 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
401 | item];
| ~~~~
include/linux/vmstat.h:407:43: error: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Werror,-Wenum-enum-conversion]
407 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
408 | NR_VM_NUMA_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~
>> include/linux/vmstat.h:414:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
414 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:419:43: error: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Werror,-Wenum-enum-conversion]
419 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
420 | NR_VM_NUMA_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:428:43: error: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Werror,-Wenum-enum-conversion]
428 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
429 | NR_VM_NUMA_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~
5 errors generated.


vim +400 include/linux/vmstat.h

9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 396
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 397 #ifdef CONFIG_NUMA
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 398 static inline const char *numa_stat_name(enum numa_stat_item item)
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 399 {
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 @400 return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 401 item];
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 402 }
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 403 #endif /* CONFIG_NUMA */
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 404
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 405 static inline const char *node_stat_name(enum node_stat_item item)
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 406 {
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 407 return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 408 NR_VM_NUMA_STAT_ITEMS +
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 409 item];
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 410 }
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 411
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 412 static inline const char *lru_list_name(enum lru_list lru)
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 413 {
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 @414 return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 415 }
9d7ea9a297e644 Konstantin Khlebnikov 2019-12-04 416

:::::: The code at line 400 was first introduced by commit
:::::: 9d7ea9a297e6445d567056f15b469dde13ca4134 mm/vmstat: add helpers to get vmstat item names for each enum type

:::::: TO: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

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