2023-10-08 00:43:55

by kernel test robot

[permalink] [raw]
Subject: [tip:x86/percpu 12/12] arch/x86/include/asm/preempt.h:27:55: sparse: sparse: incompatible types for operation (&):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/percpu
head: ca4256348660cb2162668ec3d13d1f921d05374a
commit: ca4256348660cb2162668ec3d13d1f921d05374a [12/12] x86/percpu: Use C for percpu read/write accessors
config: x86_64-randconfig-122-20231007 (https://download.01.org/0day-ci/archive/20231008/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231008/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)
kernel/bpf/percpu_freelist.c: note: in included file (through arch/x86/include/asm/preempt.h, include/linux/preempt.h, include/linux/spinlock.h, ...):
arch/x86/include/asm/percpu.h:550:49: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/percpu.h:550:49: sparse: sparse: got __seg_gs
arch/x86/include/asm/percpu.h:564:33: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/percpu.h:564:33: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c: note: in included file (through arch/x86/include/asm/cpufeature.h, arch/x86/include/asm/thread_info.h, include/linux/thread_info.h, ...):
arch/x86/include/asm/processor.h:504:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/processor.h:504:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/processor.h:504:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/processor.h:504:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/processor.h:504:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/processor.h:504:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/processor.h:504:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/processor.h:504:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c: note: in included file (through include/linux/preempt.h, include/linux/spinlock.h, kernel/bpf/percpu_freelist.h):
arch/x86/include/asm/preempt.h:27:16: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:27:16: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:34:15: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:34:15: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:38:19: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:38:19: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:61:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:61:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:66:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:66:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:71:18: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:71:18: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:80:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:80:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:80:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:80:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:80:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:80:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:85:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:85:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:85:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:85:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:85:9: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:85:9: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:95:16: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:95:16: sparse: sparse: got __seg_gs
arch/x86/include/asm/preempt.h:104:16: sparse: sparse: Expected ) at end of cast operator
arch/x86/include/asm/preempt.h:104:16: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:61:20: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:86:39: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:86:39: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:127:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: Expected ) at end of cast operator
kernel/bpf/percpu_freelist.c:159:9: sparse: sparse: got __seg_gs
>> arch/x86/include/asm/preempt.h:27:55: sparse: sparse: incompatible types for operation (&):
>> arch/x86/include/asm/preempt.h:27:55: sparse: void
>> arch/x86/include/asm/preempt.h:27:55: sparse: unsigned int
>> arch/x86/include/asm/preempt.h:27:55: sparse: sparse: incompatible types for operation (&):
>> arch/x86/include/asm/preempt.h:27:55: sparse: void
>> arch/x86/include/asm/preempt.h:27:55: sparse: unsigned int

vim +27 arch/x86/include/asm/preempt.h

ba1f14fbe70965 Peter Zijlstra 2013-11-28 20
c2daa3bed53a81 Peter Zijlstra 2013-08-14 21 /*
c2daa3bed53a81 Peter Zijlstra 2013-08-14 22 * We mask the PREEMPT_NEED_RESCHED bit so as not to confuse all current users
c2daa3bed53a81 Peter Zijlstra 2013-08-14 23 * that think a non-zero value indicates we cannot preempt.
c2daa3bed53a81 Peter Zijlstra 2013-08-14 24 */
c2daa3bed53a81 Peter Zijlstra 2013-08-14 25 static __always_inline int preempt_count(void)
c2daa3bed53a81 Peter Zijlstra 2013-08-14 26 {
64701838bf0575 Thomas Gleixner 2022-09-15 @27 return raw_cpu_read_4(pcpu_hot.preempt_count) & ~PREEMPT_NEED_RESCHED;
c2daa3bed53a81 Peter Zijlstra 2013-08-14 28 }
c2daa3bed53a81 Peter Zijlstra 2013-08-14 29

:::::: The code at line 27 was first introduced by commit
:::::: 64701838bf0575ef8acb1ad2db5934e864f3e6c3 x86/percpu: Move preempt_count next to current_task

:::::: TO: Thomas Gleixner <[email protected]>
:::::: CC: Peter Zijlstra <[email protected]>

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


2023-12-01 13:57:57

by Uros Bizjak

[permalink] [raw]
Subject: Re: [tip:x86/percpu 12/12] arch/x86/include/asm/preempt.h:27:55: sparse: sparse: incompatible types for operation (&):

On Sun, Oct 8, 2023 at 2:43 AM kernel test robot <[email protected]> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/percpu
> head: ca4256348660cb2162668ec3d13d1f921d05374a
> commit: ca4256348660cb2162668ec3d13d1f921d05374a [12/12] x86/percpu: Use C for percpu read/write accessors
> config: x86_64-randconfig-122-20231007 (https://download.01.org/0day-ci/archive/20231008/[email protected]/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231008/[email protected]/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 <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> sparse warnings: (new ones prefixed by >>)
> kernel/bpf/percpu_freelist.c: note: in included file (through arch/x86/include/asm/preempt.h, include/linux/preempt.h, include/linux/spinlock.h, ...):
> arch/x86/include/asm/percpu.h:550:49: sparse: sparse: Expected ) at end of cast operator
> arch/x86/include/asm/percpu.h:550:49: sparse: sparse: got __seg_gs
> arch/x86/include/asm/percpu.h:564:33: sparse: sparse: Expected ) at end of cast operator
> arch/x86/include/asm/percpu.h:564:33: sparse: sparse: got __seg_gs

sparse is too strict here. The following code is perfectly legal:

--cut here--
int __seg_gs foo;

int bar (int *pcp)
{
return *(typeof (*pcp) __seg_gs *)(unsigned long)(pcp);
}
--cut here--

$ gcc -O2 -S -Wextra -Wall test.c
$
$ sparse test.c
test.c:1:14: error: Expected ; at end of declaration
test.c:1:14: error: got foo
test.c:5:26: error: Expected ) at end of cast operator
test.c:5:26: error: got __seg_gs
$

Uros.