From: SeongJae Park <sj@kernel.org>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: SeongJae Park <sj@kernel.org>,
damon@lists.linux.dev, jiayuan.chen@shopee.com,
Andrew Morton <akpm@linux-foundation.org>,
Shu Anzai <shu17az@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] mm/damon/tests/core-kunit: test split above max_nr_regions/2
Date: Fri, 26 Jun 2026 07:54:14 -0700 [thread overview]
Message-ID: <20260626145415.88225-1-sj@kernel.org> (raw)
In-Reply-To: <20260626085851.70754-3-jiayuan.chen@linux.dev>
On Fri, 26 Jun 2026 16:58:38 +0800 Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> From: Jiayuan Chen <jiayuan.chen@shopee.com>
>
> Add a test that exercises kdamond_split_regions() when the total
> region count is already above max_nr_regions / 2, asserting that the
> function still splits a fraction of the regions (makes progress) and
> does not overshoot max_nr_regions.
>
> The region size and min_region_sz are picked so the split arithmetic
> does not depend on the page size.
>
> All tests pass:
> damon: pass:31 fail:0 skip:0 total:31
> Totals: pass:31 fail:0 skip:0 total:31
Nice!
>
> Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
I have trivial comments below, though.
> ---
> mm/damon/tests/core-kunit.h | 64 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 64 insertions(+)
>
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index 29fbe495e532..6fe7abcd670d 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -341,6 +341,69 @@ static void damon_test_split_regions_of(struct kunit *test)
> damon_destroy_ctx(c);
> }
>
> +/*
> + * When the total region count is already above max_nr_regions / 2,
> + * kdamond_split_regions() must keep refining the resolution by splitting a
> + * fraction of the regions (making progress), without exceeding
> + * max_nr_regions.
> + */
> +static void damon_test_split_above_half_progresses(struct kunit *test)
> +{
> + struct damon_ctx *c;
> + struct damon_target *t;
> + struct damon_region *r;
> + unsigned long start;
> + unsigned int nr_before, nr_after, i;
> + const unsigned int nr_init = 760;
> + const unsigned long region_sz = 100;
> +
> + c = damon_new_ctx();
> + if (!c)
> + kunit_skip(test, "ctx alloc fail");
> +
> + /* Keep the split arithmetic independent of the page size */
> + c->min_region_sz = 1;
> + c->attrs.min_nr_regions = 10;
> + c->attrs.max_nr_regions = 1500;
> +
> + t = damon_new_target();
> + if (!t) {
> + damon_destroy_ctx(c);
> + kunit_skip(test, "target alloc fail");
> + }
> +
> + for (i = 0; i < nr_init; i++) {
> + start = i * region_sz;
> + r = damon_new_region(start, start + region_sz);
> + if (!r) {
> + damon_free_target(t);
> + damon_destroy_ctx(c);
> + kunit_skip(test, "region alloc fail");
> + }
> + r->nr_accesses = (i & 1) ? 0 : 100;
> + r->age = 5;
> + damon_add_region(r, t);
> + }
> +
> + damon_add_target(c, t);
> +
> + nr_before = damon_nr_regions(t);
> + /* Above max_nr_regions / 2, so the blanket-split path is skipped */
> + KUNIT_EXPECT_GT(test, (unsigned long)nr_before,
> + c->attrs.max_nr_regions / 2);
Above KUNIT_EXPECT_GT() feels unnecessary.
> +
> + kdamond_split_regions(c);
> +
> + nr_after = damon_nr_regions(t);
> + /* Still made progress ... */
> + KUNIT_EXPECT_GT(test, nr_after, nr_before);
> + /* ... but did not overshoot the configured maximum */
> + KUNIT_EXPECT_LE(test, (unsigned long)nr_after,
> + c->attrs.max_nr_regions);
In future, we may do this multiple times.
> +
> + damon_destroy_ctx(c);
> +}
> +
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-06-26 14:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 8:58 [PATCH v2 0/2] mm/damon/core: detect internal variation above max_nr_regions/2 Jiayuan Chen
2026-06-26 8:58 ` [PATCH v2 1/2] mm/damon/core: split a fraction of regions when nr_regions exceeds max/2 Jiayuan Chen
2026-06-26 14:46 ` SeongJae Park
2026-06-26 8:58 ` [PATCH v2 2/2] mm/damon/tests/core-kunit: test split above max_nr_regions/2 Jiayuan Chen
2026-06-26 14:54 ` SeongJae Park [this message]
2026-06-26 14:59 ` [PATCH v2 0/2] mm/damon/core: detect internal variation " 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=20260626145415.88225-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=jiayuan.chen@linux.dev \
--cc=jiayuan.chen@shopee.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shu17az@gmail.com \
/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