* [linux-next:master 3383/4377] include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
@ 2025-02-19 4:51 kernel test robot
2025-02-19 9:38 ` Alexandre Ghiti
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2025-02-19 4:51 UTC (permalink / raw)
To: Andreas Schwab
Cc: oe-kbuild-all, Palmer Dabbelt, Alexandre Ghiti, Andrew Jones
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: e5d3fd687aac5eceb1721fa92b9f49afcf4c3717
commit: 1898300abf3508bca152e65b36cce5bf93d7e63e [3383/4377] riscv/atomic: Do proper sign extension also for unsigned in arch_cmpxchg
config: riscv-randconfig-r111-20250219 (https://download.01.org/0day-ci/archive/20250219/202502191201.7fARkW7m-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce: (https://download.01.org/0day-ci/archive/20250219/202502191201.7fARkW7m-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502191201.7fARkW7m-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
lib/atomic64_test.c: note: in included file (through include/linux/atomic.h):
>> include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
include/linux/atomic/atomic-arch-fallback.h:4181:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
include/linux/atomic/atomic-arch-fallback.h:4209:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
include/linux/atomic/atomic-arch-fallback.h:4234:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
>> include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
include/linux/atomic/atomic-arch-fallback.h:4181:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
include/linux/atomic/atomic-arch-fallback.h:4209:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
include/linux/atomic/atomic-arch-fallback.h:4234:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
vim +4152 include/linux/atomic/atomic-arch-fallback.h
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4126
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4127 /**
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4128 * raw_atomic64_cmpxchg() - atomic compare and exchange with full ordering
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4129 * @v: pointer to atomic64_t
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4130 * @old: s64 value to compare with
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4131 * @new: s64 value to assign
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4132 *
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4133 * If (@v == @old), atomically updates @v to @new with full ordering.
6dfee110c6cc7a include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2024-02-09 4134 * Otherwise, @v is not modified and relaxed ordering is provided.
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4135 *
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4136 * Safe to use in noinstr code; prefer atomic64_cmpxchg() elsewhere.
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4137 *
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4138 * Return: The original value of @v.
ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4139 */
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4140 static __always_inline s64
9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4141 raw_atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new)
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4142 {
1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4143 #if defined(arch_atomic64_cmpxchg)
1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4144 return arch_atomic64_cmpxchg(v, old, new);
1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4145 #elif defined(arch_atomic64_cmpxchg_relaxed)
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4146 s64 ret;
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4147 __atomic_pre_full_fence();
9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4148 ret = arch_atomic64_cmpxchg_relaxed(v, old, new);
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4149 __atomic_post_full_fence();
37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4150 return ret;
9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4151 #else
9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 @4152 return raw_cmpxchg(&v->counter, old, new);
d12157efc8e083 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4153 #endif
1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4154 }
d12157efc8e083 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4155
:::::: The code at line 4152 was first introduced by commit
:::::: 9257959a6e5b4fca6fc8e985790bff62c2046f20 locking/atomic: scripts: restructure fallback ifdeffery
:::::: TO: Mark Rutland <mark.rutland@arm.com>
:::::: CC: Peter Zijlstra <peterz@infradead.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 3383/4377] include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
2025-02-19 4:51 [linux-next:master 3383/4377] include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d) kernel test robot
@ 2025-02-19 9:38 ` Alexandre Ghiti
2025-02-19 9:55 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Ghiti @ 2025-02-19 9:38 UTC (permalink / raw)
To: kernel test robot
Cc: Andreas Schwab, oe-kbuild-all, Palmer Dabbelt, Andrew Jones
On Wed, Feb 19, 2025 at 5:52 AM kernel test robot <lkp@intel.com> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head: e5d3fd687aac5eceb1721fa92b9f49afcf4c3717
> commit: 1898300abf3508bca152e65b36cce5bf93d7e63e [3383/4377] riscv/atomic: Do proper sign extension also for unsigned in arch_cmpxchg
> config: riscv-randconfig-r111-20250219 (https://download.01.org/0day-ci/archive/20250219/202502191201.7fARkW7m-lkp@intel.com/config)
> compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
> reproduce: (https://download.01.org/0day-ci/archive/20250219/202502191201.7fARkW7m-lkp@intel.com/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@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202502191201.7fARkW7m-lkp@intel.com/
>
> sparse warnings: (new ones prefixed by >>)
> lib/atomic64_test.c: note: in included file (through include/linux/atomic.h):
> >> include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
> include/linux/atomic/atomic-arch-fallback.h:4181:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
> include/linux/atomic/atomic-arch-fallback.h:4209:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
> include/linux/atomic/atomic-arch-fallback.h:4234:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
> >> include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
> include/linux/atomic/atomic-arch-fallback.h:4181:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
> include/linux/atomic/atomic-arch-fallback.h:4209:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
> include/linux/atomic/atomic-arch-fallback.h:4234:16: sparse: sparse: cast truncates bits from constant value (faceabadf00df001 becomes f00df001)
>
> vim +4152 include/linux/atomic/atomic-arch-fallback.h
>
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4126
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4127 /**
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4128 * raw_atomic64_cmpxchg() - atomic compare and exchange with full ordering
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4129 * @v: pointer to atomic64_t
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4130 * @old: s64 value to compare with
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4131 * @new: s64 value to assign
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4132 *
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4133 * If (@v == @old), atomically updates @v to @new with full ordering.
> 6dfee110c6cc7a include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2024-02-09 4134 * Otherwise, @v is not modified and relaxed ordering is provided.
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4135 *
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4136 * Safe to use in noinstr code; prefer atomic64_cmpxchg() elsewhere.
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4137 *
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4138 * Return: The original value of @v.
> ad8110706f3811 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4139 */
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4140 static __always_inline s64
> 9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4141 raw_atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new)
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4142 {
> 1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4143 #if defined(arch_atomic64_cmpxchg)
> 1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4144 return arch_atomic64_cmpxchg(v, old, new);
> 1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4145 #elif defined(arch_atomic64_cmpxchg_relaxed)
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4146 s64 ret;
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4147 __atomic_pre_full_fence();
> 9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4148 ret = arch_atomic64_cmpxchg_relaxed(v, old, new);
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4149 __atomic_post_full_fence();
> 37f8173dd84936 include/linux/atomic-arch-fallback.h Peter Zijlstra 2020-01-24 4150 return ret;
> 9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4151 #else
> 9257959a6e5b4f include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 @4152 return raw_cmpxchg(&v->counter, old, new);
> d12157efc8e083 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4153 #endif
> 1d78814d41701c include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4154 }
> d12157efc8e083 include/linux/atomic/atomic-arch-fallback.h Mark Rutland 2023-06-05 4155
>
> :::::: The code at line 4152 was first introduced by commit
> :::::: 9257959a6e5b4fca6fc8e985790bff62c2046f20 locking/atomic: scripts: restructure fallback ifdeffery
>
> :::::: TO: Mark Rutland <mark.rutland@arm.com>
> :::::: CC: Peter Zijlstra <peterz@infradead.org>
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
I don't get it, everything here is 64-bit and commit "riscv/atomic: Do
proper sign extension also for unsigned in arch_cmpxchg" introduced a
cast *only* for 32-bit values. Could that be a false-positive?
Thanks,
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 3383/4377] include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d)
2025-02-19 9:38 ` Alexandre Ghiti
@ 2025-02-19 9:55 ` Andreas Schwab
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2025-02-19 9:55 UTC (permalink / raw)
To: Alexandre Ghiti
Cc: kernel test robot, oe-kbuild-all, Palmer Dabbelt, Andrew Jones
On Feb 19 2025, Alexandre Ghiti wrote:
> I don't get it, everything here is 64-bit and commit "riscv/atomic: Do
> proper sign extension also for unsigned in arch_cmpxchg" introduced a
> cast *only* for 32-bit values. Could that be a false-positive?
Yes, it is. All the arch_cmpxchg macros are type-generic macros, and
the path that casts the value is never executed if sizeof(*__ptr) == 8,
but sparse does not understand that (and gcc doesn't either when it
generates the -Wpointer-to-int-cast warning).
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-19 9:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 4:51 [linux-next:master 3383/4377] include/linux/atomic/atomic-arch-fallback.h:4152:16: sparse: sparse: cast truncates bits from constant value (aaa31337c001d00d becomes c001d00d) kernel test robot
2025-02-19 9:38 ` Alexandre Ghiti
2025-02-19 9:55 ` Andreas Schwab
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.