From: SJ Park <sj@kernel.org>
To: Kunwu Chan <kunwu.chan@gmail.com>
Cc: SJ Park <sj@kernel.org>,
akpm@linux-foundation.org, lianux.mm@gmail.com,
damon@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/damon/tests/core-kunit: improve nr_samples_per_aggr test isolation
Date: Tue, 8 Sep 2026 06:36:50 -0700 [thread overview]
Message-ID: <20260908133651.96278-1-sj@kernel.org> (raw)
In-Reply-To: <20260908063635.2208922-1-kunwu.chan@gmail.com>
Hi Kunwu,
On Tue, 8 Sep 2026 14:36:35 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote:
> The damon_nr_samples_per_aggr() test sets both intervals to zero,
> which exercises two different fallback paths at once.
>
> Use separate compound initializers for each case so that each case
> tests one fallback path independently. Also make the overflow case
> use an explicit non-zero sample interval so that it does not depend
> on the zero sample interval fallback.
Thank you for sharing this patch!
>
> Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
> ---
> mm/damon/tests/core-kunit.h | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index c01e6a75cad..ff23208c181 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -627,12 +627,20 @@ static void damon_test_set_regions(struct kunit *test)
>
> static void damon_test_nr_samples_per_aggr(struct kunit *test)
> {
> - struct damon_attrs attrs = {
> + struct damon_attrs attrs;
> +
> + /* Zero sample interval is treated as one. */
> + attrs = (struct damon_attrs){
> .sample_interval = 0,
> - .aggr_interval = 0,
> + .aggr_interval = 5000,
> };
> + KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs), 5000);
Thank you for adding this test case.
>
> - /* Zero aggregation interval doesn't cause division by zero */
> + /* Zero samples per aggregation is treated as one. */
> + attrs = (struct damon_attrs){
> + .sample_interval = 5000,
> + .aggr_interval = 0,
> + };
> KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs), 1);
But damon_set_attrs() disallows sample intervals that are larger than the
aggregation intervals. Hence this setup is somewhat unrealistic. Should we
set sample_interval zero?
>
> /*
> @@ -640,7 +648,10 @@ static void damon_test_nr_samples_per_aggr(struct kunit *test)
> * overflow
> */
> if (ULONG_MAX > UINT_MAX) {
> - attrs.aggr_interval = (unsigned long)UINT_MAX + 1;
> + attrs = (struct damon_attrs){
> + .sample_interval = 1,
> + .aggr_interval = (unsigned long)UINT_MAX + 1,
> + };
> KUNIT_EXPECT_EQ(test, damon_nr_samples_per_aggr(&attrs),
> UINT_MAX);
> }
>
> base-commit: d118502628f8b673be9023db8bdf878f64a7ed45
> --
> 2.43.0
Thanks,
SJ
next prev parent reply other threads:[~2026-09-08 13:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 6:36 [PATCH] mm/damon/tests/core-kunit: improve nr_samples_per_aggr test isolation Kunwu Chan
2026-09-08 6:48 ` Lian Wang
2026-09-08 13:36 ` SJ Park [this message]
2026-09-09 3:54 ` Kunwu Chan
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=20260908133651.96278-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=kunwu.chan@gmail.com \
--cc=lianux.mm@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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