DAMON development mailing list
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand()
Date: Thu, 25 Jun 2026 17:39:49 -0700	[thread overview]
Message-ID: <20260626003950.87863-1-sj@kernel.org> (raw)
In-Reply-To: <20260626002519.C1BBB1F000E9@smtp.kernel.org>

On Fri, 26 Jun 2026 00:25:19 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Incomplete test coverage: the test misses the 64-bit execution branch of damon_rand().
> --
> 
> commit e5514cf11386fbde6faace5ed2dc4b93fedc4bf8
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/tests/core-kunit: test damon_rand()
> 
> This commit adds a KUnit test for the recently introduced lockless PRNG in
> damon_rand(). It validates that the generated numbers stay within the
> requested bounds.
> 
> > diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> > index 1cfb8c176b873..282670b0fa908 100644
> > --- a/mm/damon/tests/core-kunit.h
> > +++ b/mm/damon/tests/core-kunit.h
> 
> [ ... ]
> 
> > @@ -1460,6 +1460,20 @@ static void damon_test_is_last_region(struct kunit *test)
> >  	damon_free_target(t);
> >  }
> >  
> > +static void damon_test_rand(struct kunit *test)
> > +{
> > +	struct damon_ctx ctx;
> > +	int i;
> > +
> > +	prandom_seed_state(&ctx.rnd_state, get_random_u64());
> > +	for (i = 0; i < 10000; i++) {
> > +		unsigned long rnd = damon_rand(&ctx, 0, 10);
> 
> [Severity: Low]
> Does this test miss the 64-bit execution branch of damon_rand()?
> 
> The damon_rand() function implements two distinct calculation paths: one for
> spans <= U32_MAX and a 64-bit fallback for larger spans using
> mul_u64_u64_shr().
> 
> Because this test hardcodes the bounds 0 and 10, the span evaluates to
> <= U32_MAX. This guarantees that only the 32-bit path is executed, leaving
> the 64-bit logic entirely untested on 64-bit architectures.
> 
> Would it be helpful to add another iteration or separate test case with a
> span greater than U32_MAX to ensure full coverage of damon_rand()?

I agree testing it together could be a good idea.  But not necessarily a
blocker of this patch.  I will consider adding more test cases including that
in future.


Thanks,
SJ

[...]

  reply	other threads:[~2026-06-26  0:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  0:16 [RFC PATCH v1.3 00/11] mm/damon: update, optimize, and clean up doc, tests, and code SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 01/11] Docs/mm/damon/design: update for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP SeongJae Park
2026-06-26  0:24   ` sashiko-bot
2026-06-26  0:31     ` SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 02/11] Docs/ABI/damon: document probe files SeongJae Park
2026-06-26  0:25   ` sashiko-bot
2026-06-26  0:34     ` SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 03/11] mm/damon/tests/core-kunit: test damon_rand() SeongJae Park
2026-06-26  0:25   ` sashiko-bot
2026-06-26  0:39     ` SeongJae Park [this message]
2026-06-26  0:16 ` [RFC PATCH v1.3 04/11] selftests/damon/sysfs.sh: test multiple probe dirs creation SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 05/11] selftests/damon/sysfs.sh: test {core,ops}_filters/ directories SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 06/11] selftests/damon/sysfs.sh: test dests dir SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 07/11] selftests/damon/sysfs.sh: test all files in quota goal dir SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 08/11] mm/damon/core: reduce range setup in damon_commit_target_regions() SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 09/11] mm/damon/sysfs: split probe setup function out SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 10/11] mm/damon/sysfs: split out filters setup function SeongJae Park
2026-06-26  0:16 ` [RFC PATCH v1.3 11/11] mm/damon/sysfs: fix typos in probe_{add,rm}_dirs: s/attr/probe/ SeongJae Park

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=20260626003950.87863-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=sashiko-bot@kernel.org \
    /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