From: SeongJae Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>,
Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <davidgow@google.com>,
damon@lists.linux.dev, kunit-dev@googlegroups.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org
Subject: [PATCH 2/7] mm/damon/tests/core-kunit: add a test for damon_is_last_region()
Date: Sat, 7 Mar 2026 11:53:50 -0800 [thread overview]
Message-ID: <20260307195356.203753-3-sj@kernel.org> (raw)
In-Reply-To: <20260307195356.203753-1-sj@kernel.org>
There was a bug [1] in damon_is_last_region(). Add a kunit test to not
reintroduce the bug.
[1] https://lore.kernel.org/20260114152049.99727-1-sj@kernel.org/
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/tests/core-kunit.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 2289f9e4610c0..e86d4f4fe261a 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -1311,6 +1311,28 @@ static void damon_test_apply_min_nr_regions(struct kunit *test)
damon_test_apply_min_nr_regions_for(test, 10, 2, 10, 2, 5);
}
+static void damon_test_is_last_region(struct kunit *test)
+{
+ struct damon_region *r;
+ struct damon_target *t;
+ int i;
+
+ t = damon_new_target();
+ if (!t)
+ kunit_skip(test, "target alloc fail\n");
+
+ for (i = 0; i < 4; i++) {
+ r = damon_new_region(i * 2, (i + 1) * 2);
+ if (!r) {
+ damon_free_target(t);
+ kunit_skip(test, "region alloc %d fail\n", i);
+ }
+ damon_add_region(r, t);
+ KUNIT_EXPECT_TRUE(test, damon_is_last_region(r, t));
+ }
+ damon_free_target(t);
+}
+
static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damon_test_target),
KUNIT_CASE(damon_test_regions),
@@ -1339,6 +1361,7 @@ static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damon_test_feed_loop_next_input),
KUNIT_CASE(damon_test_set_filters_default_reject),
KUNIT_CASE(damon_test_apply_min_nr_regions),
+ KUNIT_CASE(damon_test_is_last_region),
{},
};
--
2.47.3
next prev parent reply other threads:[~2026-03-07 19:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 19:53 [PATCH 0/7] mm/damon: improve/fixup/update ratio calculation, test and documentation SeongJae Park
2026-03-07 19:53 ` [PATCH 1/7] mm/damon/core: use mult_frac() SeongJae Park
2026-03-07 19:53 ` SeongJae Park [this message]
2026-03-09 2:34 ` [PATCH 2/7] mm/damon/tests/core-kunit: add a test for damon_is_last_region() wang lian
2026-03-07 19:53 ` [PATCH 3/7] mm/damon/core: clarify damon_set_attrs() usages SeongJae Park
2026-03-07 19:53 ` [PATCH 4/7] mm/damon: document non-zero length damon_region assumption SeongJae Park
2026-03-07 19:53 ` [PATCH 5/7] Docs/admin-guide/mm/damn/lru_sort: fix intervals autotune parameter name SeongJae Park
2026-03-07 19:53 ` [PATCH 6/7] Docs/mm/damon/maintainer-profile: use flexible review cadence SeongJae Park
2026-03-07 19:53 ` [PATCH 7/7] Docs/mm/damon/index: fix typo: autoamted -> automated SeongJae Park
2026-03-09 2:27 ` [PATCH 0/7] mm/damon: improve/fixup/update ratio calculation, test and documentation wang lian
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=20260307195356.203753-3-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brendan.higgins@linux.dev \
--cc=damon@lists.linux.dev \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@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