Re: include/linux/hugetlb.h:916:20: error: static declaration of 'arch_hugetlb_migration_supported' follows non-static declaration

From: Alexandre Ghiti
Date: Wed Feb 14 2024 - 07:16:51 EST


On Wed, Feb 14, 2024 at 1:09 PM kernel test robot <lkp@xxxxxxxxx> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 7e90b5c295ec1e47c8ad865429f046970c549a66
> commit: ce68c035457bdd025a9961e0ba2157323090c581 riscv: Fix arch_hugetlb_migration_supported() for NAPOT
> date: 7 days ago
> config: riscv-randconfig-r064-20240214 (https://download.01.org/0day-ci/archive/20240214/202402142035.Aq7hibAu-lkp@xxxxxxxxx/config)
> compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project c08b90c50bcac9f3f563c79491c8dbcbe7c3b574)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402142035.Aq7hibAu-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/202402142035.Aq7hibAu-lkp@xxxxxxxxx/
>
> All errors (new ones prefixed by >>):
>
> In file included from kernel/fork.c:52:
> >> include/linux/hugetlb.h:916:20: error: static declaration of 'arch_hugetlb_migration_supported' follows non-static declaration
> 916 | static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> | ^
> arch/riscv/include/asm/hugetlb.h:15:42: note: expanded from macro 'arch_hugetlb_migration_supported'
> 15 | #define arch_hugetlb_migration_supported arch_hugetlb_migration_supported
> | ^
> arch/riscv/include/asm/hugetlb.h:14:6: note: previous declaration is here
> 14 | bool arch_hugetlb_migration_supported(struct hstate *h);
> | ^
> 1 error generated.
> --
> In file included from kernel/sysctl.c:45:
> >> include/linux/hugetlb.h:916:20: error: static declaration of 'arch_hugetlb_migration_supported' follows non-static declaration
> 916 | static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> | ^
> arch/riscv/include/asm/hugetlb.h:15:42: note: expanded from macro 'arch_hugetlb_migration_supported'
> 15 | #define arch_hugetlb_migration_supported arch_hugetlb_migration_supported
> | ^
> arch/riscv/include/asm/hugetlb.h:14:6: note: previous declaration is here
> 14 | bool arch_hugetlb_migration_supported(struct hstate *h);
> | ^
> In file included from kernel/sysctl.c:53:
> In file included from include/linux/nfs_fs.h:31:
> In file included from include/linux/sunrpc/auth.h:13:
> In file included from include/linux/sunrpc/sched.h:19:
> include/linux/sunrpc/xdr.h:782:46: warning: result of comparison of constant 4611686018427387903 with expression of type '__u32' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
> 782 | if (U32_MAX >= SIZE_MAX / sizeof(*p) && len > SIZE_MAX / sizeof(*p))
> | ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
> 1 warning and 1 error generated.
> --
> In file included from kernel/events/core.c:31:
> >> include/linux/hugetlb.h:916:20: error: static declaration of 'arch_hugetlb_migration_supported' follows non-static declaration
> 916 | static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> | ^
> arch/riscv/include/asm/hugetlb.h:15:42: note: expanded from macro 'arch_hugetlb_migration_supported'
> 15 | #define arch_hugetlb_migration_supported arch_hugetlb_migration_supported
> | ^
> arch/riscv/include/asm/hugetlb.h:14:6: note: previous declaration is here
> 14 | bool arch_hugetlb_migration_supported(struct hstate *h);
> | ^
> In file included from kernel/events/core.c:43:
> include/linux/mman.h:158:9: warning: division by zero is undefined [-Wdivision-by-zero]
> 158 | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) |
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/linux/mman.h:136:21: note: expanded from macro '_calc_vm_trans'
> 136 | : ((x) & (bit1)) / ((bit1) / (bit2))))
> | ^ ~~~~~~~~~~~~~~~~~
> 1 warning and 1 error generated.
>
>
> vim +/arch_hugetlb_migration_supported +916 include/linux/hugetlb.h
>
> 161df60e9e8965 Naoya Horiguchi 2022-07-14 902
> c177c81e09e517 Naoya Horiguchi 2014-06-04 903 #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION
> e693de186414ae Anshuman Khandual 2019-03-05 904 #ifndef arch_hugetlb_migration_supported
> e693de186414ae Anshuman Khandual 2019-03-05 905 static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> e693de186414ae Anshuman Khandual 2019-03-05 906 {
> 94310cbcaa3c2b Anshuman Khandual 2017-07-06 907 if ((huge_page_shift(h) == PMD_SHIFT) ||
> 9b553bf5eb99dd Anshuman Khandual 2019-03-05 908 (huge_page_shift(h) == PUD_SHIFT) ||
> 94310cbcaa3c2b Anshuman Khandual 2017-07-06 909 (huge_page_shift(h) == PGDIR_SHIFT))
> 94310cbcaa3c2b Anshuman Khandual 2017-07-06 910 return true;
> 94310cbcaa3c2b Anshuman Khandual 2017-07-06 911 else
> 94310cbcaa3c2b Anshuman Khandual 2017-07-06 912 return false;
> e693de186414ae Anshuman Khandual 2019-03-05 913 }
> e693de186414ae Anshuman Khandual 2019-03-05 914 #endif
> c177c81e09e517 Naoya Horiguchi 2014-06-04 915 #else
> e693de186414ae Anshuman Khandual 2019-03-05 @916 static inline bool arch_hugetlb_migration_supported(struct hstate *h)
> e693de186414ae Anshuman Khandual 2019-03-05 917 {
> d70c17d436b3fb Chen Gang 2016-05-20 918 return false;
> e693de186414ae Anshuman Khandual 2019-03-05 919 }
> c177c81e09e517 Naoya Horiguchi 2014-06-04 920 #endif
> e693de186414ae Anshuman Khandual 2019-03-05 921
>
> :::::: The code at line 916 was first introduced by commit
> :::::: e693de186414ae66f2a316ff9befcd2b7a6d07b6 mm/hugetlb: enable arch specific huge page size support for migration
>
> :::::: TO: Anshuman Khandual <anshuman.khandual@xxxxxxx>
> :::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

I sent a fix for this a few days ago here:
https://lore.kernel.org/linux-riscv/20240211083640.756583-1-alexghiti@xxxxxxxxxxxx/T/#u