From: SeongJae Park <sj@kernel.org>
To: kernel test robot <lkp@intel.com>
Cc: SeongJae Park <sj@kernel.org>,
Jiayuan Chen <jiayuan.chen@shopee.com>,
oe-kbuild-all@lists.linux.dev,
David Hildenbrand <david@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
mm-commits@vger.kernel.org, damon@lists.linux.dev
Subject: Re: [akpm-mm:mm-new 222/223] include/linux/damon.h:869 damon_rand() warn: always true condition '(span <= (~0)) => (0-u32max <= u32max)'
Date: Sat, 9 May 2026 09:22:01 -0700 [thread overview]
Message-ID: <20260509162202.114645-1-sj@kernel.org> (raw)
In-Reply-To: <202605092036.9mdDJbEZ-lkp@intel.com>
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
[...]
prev parent reply other threads:[~2026-05-09 16:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260509162202.114645-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=david@kernel.org \
--cc=jiayuan.chen@shopee.com \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=mm-commits@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox