Re: include/linux/smp.h:34:33: error: requested alignment '20' is not a positive power of 2

From: Helge Deller
Date: Sun Feb 13 2022 - 15:45:21 EST


On 2/13/22 10:59, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: b81b1829e7e39f6cebdf6e4d5484eacbceda8554
> commit: 5f6e0fe01b6b33894cf6f61b359ab5a6d2b7674e parisc: Fix compile failure when building 64-bit kernel natively
> date: 6 months ago
> config: parisc-randconfig-r004-20220213 (https://download.01.org/0day-ci/archive/20220213/202202131741.c6BPpfzd-lkp@xxxxxxxxx/config)
> compiler: hppa64-linux-gcc (GCC) 11.2.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5f6e0fe01b6b33894cf6f61b359ab5a6d2b7674e
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 5f6e0fe01b6b33894cf6f61b359ab5a6d2b7674e
> # save the config file to linux build tree
> mkdir build_dir
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=parisc prepare
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All error/warnings (new ones prefixed by >>):
>
> In file included from arch/parisc/include/asm/bitops.h:203,
> from include/linux/bitops.h:32,
> from include/linux/kernel.h:12,
> from arch/parisc/include/asm/bug.h:5,
> from include/linux/bug.h:5,
> from include/linux/page-flags.h:10,
> from kernel/bounds.c:10:
> include/asm-generic/bitops/__fls.h: In function '__fls':
>>> include/asm-generic/bitops/__fls.h:18:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 18 | if (!(word & (~0ul << 32))) {


This kind of build error usually happens if you use the 64-bit compiler
(hppa64-linux-gcc) to compile a kernel config for a 32-bit kernel.

Looking at the config:
> config: parisc-randconfig-r004-20220213 (https://download.01.org/0day-ci/archive/20220213/202202131741.c6BPpfzd-lkp@xxxxxxxxx/config)
CONFIG_64BIT is set to Y, so that's correct here.

But this is how you call the compiler:
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=parisc prepare

The "ARCH=parisc" is wrong in this case.
You need:
"ARCH=parisc64".
This is starting with Linux kernel 5.14.
Before "ARCH=parisc" worked for 32- and 64-bit kernels.

Can you adjust the call command?

Helge



> | ^~
> include/asm-generic/bitops/__fls.h:20:22: warning: left shift count >= width of type [-Wshift-count-overflow]
> 20 | word <<= 32;
> | ^~~
> include/asm-generic/bitops/__fls.h:23:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 23 | if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:27:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 27 | if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:31:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 31 | if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:35:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 35 | if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:39:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 39 | if (!(word & (~0ul << (BITS_PER_LONG-1))))
> | ^~
> In file included from arch/parisc/include/asm/bitops.h:203,
> from include/linux/bitops.h:32,
> from include/linux/kernel.h:12,
> from arch/parisc/include/asm/bug.h:5,
> from include/linux/bug.h:5,
> from include/linux/thread_info.h:13,
> from include/asm-generic/current.h:5,
> from ./arch/parisc/include/generated/asm/current.h:1,
> from include/linux/sched.h:12,
> from arch/parisc/kernel/asm-offsets.c:18:
> include/asm-generic/bitops/__fls.h: In function '__fls':
>>> include/asm-generic/bitops/__fls.h:18:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 18 | if (!(word & (~0ul << 32))) {
> | ^~
> include/asm-generic/bitops/__fls.h:20:22: warning: left shift count >= width of type [-Wshift-count-overflow]
> 20 | word <<= 32;
> | ^~~
> include/asm-generic/bitops/__fls.h:23:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 23 | if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:27:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 27 | if (!(word & (~0ul << (BITS_PER_LONG-8)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:31:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 31 | if (!(word & (~0ul << (BITS_PER_LONG-4)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:35:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 35 | if (!(word & (~0ul << (BITS_PER_LONG-2)))) {
> | ^~
> include/asm-generic/bitops/__fls.h:39:28: warning: left shift count >= width of type [-Wshift-count-overflow]
> 39 | if (!(word & (~0ul << (BITS_PER_LONG-1))))
> | ^~
> In file included from arch/parisc/include/asm/processor.h:17,
> from arch/parisc/include/asm/thread_info.h:8,
> from include/linux/thread_info.h:60,
> from include/asm-generic/current.h:5,
> from ./arch/parisc/include/generated/asm/current.h:1,
> from include/linux/sched.h:12,
> from arch/parisc/kernel/asm-offsets.c:18:
> arch/parisc/include/asm/pdc.h: At top level:
>>> arch/parisc/include/asm/pdc.h:75:24: warning: 'struct pdc_memory_table' declared inside parameter list will not be visible outside of this definition or declaration
> 75 | struct pdc_memory_table *tbl, unsigned long entries);
> | ^~~~~~~~~~~~~~~~
>>> arch/parisc/include/asm/pdc.h:74:30: warning: 'struct pdc_memory_table_raddr' declared inside parameter list will not be visible outside of this definition or declaration
> 74 | int pdc_mem_mem_table(struct pdc_memory_table_raddr *r_addr,
> | ^~~~~~~~~~~~~~~~~~~~~~
> In file included from include/linux/compiler_types.h:65,
> from <command-line>:
>>> include/linux/smp.h:34:33: error: requested alignment '20' is not a positive power of 2
> 34 | __aligned(sizeof(struct __call_single_data));
> | ^~~~~~~~~~~~~~~~~~
> include/linux/compiler_attributes.h:53:68: note: in definition of macro '__aligned'
> 53 | #define __aligned(x) __attribute__((__aligned__(x)))
> | ^
> In file included from include/linux/mm.h:33,
> from include/linux/pid_namespace.h:7,
> from include/linux/ptrace.h:10,
> from arch/parisc/kernel/asm-offsets.c:20:
> include/linux/pgtable.h: In function 'pud_index':
>>> include/linux/pgtable.h:77:25: warning: right shift count >= width of type [-Wshift-count-overflow]
> 77 | return (address >> PUD_SHIFT) & (PTRS_PER_PUD - 1);
> | ^~
> include/linux/pgtable.h: In function 'pgd_offset_pgd':
> include/linux/pgtable.h:84:29: warning: right shift count >= width of type [-Wshift-count-overflow]
> 84 | #define pgd_index(a) (((a) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
> | ^~
> include/linux/pgtable.h:124:23: note: in expansion of macro 'pgd_index'
> 124 | return (pgd + pgd_index(address));
> | ^~~~~~~~~
> In file included from include/linux/stringhash.h:7,
> from include/linux/dcache.h:15,
> from include/linux/fs.h:8,
> from include/linux/huge_mm.h:8,
> from include/linux/mm.h:728,
> from include/linux/pid_namespace.h:7,
> from include/linux/ptrace.h:10,
> from arch/parisc/kernel/asm-offsets.c:20:
> include/linux/hash.h: In function 'hash32_ptr':
>>> include/linux/hash.h:99:21: warning: right shift count >= width of type [-Wshift-count-overflow]
> 99 | val ^= (val >> 32);
> | ^~
> In file included from arch/parisc/kernel/asm-offsets.c:22:
> arch/parisc/kernel/asm-offsets.c: In function 'main':
>>> arch/parisc/kernel/asm-offsets.c:271:43: warning: right shift count >= width of type [-Wshift-count-overflow]
> 271 | DEFINE(ASM_PGD_ENTRY, PAGE_OFFSET >> PGDIR_SHIFT);
> | ^~
> include/linux/kbuild.h:6:69: note: in definition of macro 'DEFINE'
> 6 | asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
> | ^~~
> make[2]: *** [scripts/Makefile.build:117: arch/parisc/kernel/asm-offsets.s] Error 1
> make[2]: Target '__build' not remade because of errors.
> make[1]: *** [Makefile:1217: prepare0] Error 2
> make[1]: Target 'prepare' not remade because of errors.
> make: *** [Makefile:220: __sub-make] Error 2
> make: Target 'prepare' not remade because of errors.
>
>
> vim +/20 +34 include/linux/smp.h
>
> 3d4422332711ef Jens Axboe 2008-06-26 28
> 545b8c8df41f9e Peter Zijlstra 2020-06-15 29 #define CSD_INIT(_func, _info) \
> 545b8c8df41f9e Peter Zijlstra 2020-06-15 30 (struct __call_single_data){ .func = (_func), .info = (_info), }
> 545b8c8df41f9e Peter Zijlstra 2020-06-15 31
> 966a967116e699 Ying Huang 2017-08-08 32 /* Use __aligned() to avoid to use 2 cache lines for 1 csd */
> 966a967116e699 Ying Huang 2017-08-08 33 typedef struct __call_single_data call_single_data_t
> 966a967116e699 Ying Huang 2017-08-08 @34 __aligned(sizeof(struct __call_single_data));
> 966a967116e699 Ying Huang 2017-08-08 35
>
> :::::: The code at line 34 was first introduced by commit
> :::::: 966a967116e699762dbf4af7f9e0d1955c25aa37 smp: Avoid using two cache lines for struct call_single_data
>
> :::::: TO: Ying Huang <ying.huang@xxxxxxxxx>
> :::::: CC: Ingo Molnar <mingo@xxxxxxxxxx>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
>