* [akpm-mm:mm-new 222/223] include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)'
@ 2026-05-09 12:44 kernel test robot
2026-05-09 16:22 ` SeongJae Park
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2026-05-09 12:44 UTC (permalink / raw)
To: Jiayuan Chen
Cc: oe-kbuild-all, David Hildenbrand, Andrew Morton,
Linux Memory Management List, mm-commits, SeongJae Park
tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-new
head: 7505bb13a9bb1f214310915ccc06643119fdafc9
commit: 8b7c38eb9621c71d288eca45c8dd4dc92357dc07 [222/223] mm/damon: replace damon_rand() with a per-ctx lockless PRNG
config: riscv-randconfig-r071-20260509 (https://download.01.org/0day-ci/archive/20260509/202605092036.9mdDJbEZ-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 8.5.0
smatch: v0.5.0-9065-ge9cc34fd
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/202605092036.9mdDJbEZ-lkp@intel.com/
smatch warnings:
include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)'
vim +869 include/linux/damon.h
861
862 /* Get a random number in [@l, @r) using @ctx's lockless PRNG. */
863 static inline unsigned long damon_rand(struct damon_ctx *ctx,
864 unsigned long l, unsigned long r)
865 {
866 unsigned long span = r - l;
867 u64 rnd;
868
> 869 if (span <= U32_MAX) {
870 rnd = prandom_u32_state(&ctx->rnd_state);
871 return l + (unsigned long)((rnd * span) >> 32);
872 }
873 rnd = ((u64)prandom_u32_state(&ctx->rnd_state) << 32) |
874 prandom_u32_state(&ctx->rnd_state);
875 return l + mul_u64_u64_shr(rnd, span, 64);
876 }
877
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [akpm-mm:mm-new 222/223] include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)'
2026-05-09 12:44 [akpm-mm:mm-new 222/223] include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)' kernel test robot
@ 2026-05-09 16:22 ` SeongJae Park
0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2026-05-09 16:22 UTC (permalink / raw)
To: kernel test robot
Cc: SeongJae Park, Jiayuan Chen, oe-kbuild-all, David Hildenbrand,
Andrew Morton, Linux Memory Management List, mm-commits, damon
On Sat, 09 May 2026 20:44:33 +0800 kernel test robot <lkp@intel.com> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-new
> head: 7505bb13a9bb1f214310915ccc06643119fdafc9
> commit: 8b7c38eb9621c71d288eca45c8dd4dc92357dc07 [222/223] mm/damon: replace damon_rand() with a per-ctx lockless PRNG
> config: riscv-randconfig-r071-20260509 (https://download.01.org/0day-ci/archive/20260509/202605092036.9mdDJbEZ-lkp@intel.com/config)
> compiler: riscv32-linux-gcc (GCC) 8.5.0
> smatch: v0.5.0-9065-ge9cc34fd
>
> 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/202605092036.9mdDJbEZ-lkp@intel.com/
>
> smatch warnings:
> include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)'
>
> vim +869 include/linux/damon.h
>
> 861
> 862 /* Get a random number in [@l, @r) using @ctx's lockless PRNG. */
> 863 static inline unsigned long damon_rand(struct damon_ctx *ctx,
> 864 unsigned long l, unsigned long r)
> 865 {
> 866 unsigned long span = r - l;
> 867 u64 rnd;
> 868
> > 869 if (span <= U32_MAX) {
> 870 rnd = prandom_u32_state(&ctx->rnd_state);
> 871 return l + (unsigned long)((rnd * span) >> 32);
> 872 }
> 873 rnd = ((u64)prandom_u32_state(&ctx->rnd_state) << 32) |
> 874 prandom_u32_state(&ctx->rnd_state);
> 875 return l + mul_u64_u64_shr(rnd, span, 64);
> 876 }
> 877
The check is for 64bit systems. I think this warning is ok to be ignored.
Please let me know if I'm missing something.
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-09 16:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-09 12:44 [akpm-mm:mm-new 222/223] include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)' kernel test robot
2026-05-09 16:22 ` SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox