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 1/2] mm/damon/tests/core-kunit: add a test for damon_commit_ctx()
Date: Sat, 7 Mar 2026 11:42:20 -0800 [thread overview]
Message-ID: <20260307194222.202075-2-sj@kernel.org> (raw)
In-Reply-To: <20260307194222.202075-1-sj@kernel.org>
Add a kunit test for confirming the change that is made on commit
c80f46ac228b ("mm/damon/core: disallow non-power of two min_region_sz")
functions as expected.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/tests/core-kunit.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 44a983fca9501..65181c6dac1b4 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -1060,6 +1060,27 @@ static void damon_test_commit_target_regions(struct kunit *test)
(unsigned long[][2]) {{3, 8}, {8, 10}}, 2);
}
+static void damon_test_commit_ctx(struct kunit *test)
+{
+ struct damon_ctx *src, *dst;
+
+ src = damon_new_ctx();
+ if (!src)
+ kunit_skip(test, "src alloc fail");
+ dst = damon_new_ctx();
+ if (!dst) {
+ damon_destroy_ctx(src);
+ kunit_skip(test, "dst alloc fail");
+ }
+ /* Only power of two min_region_sz is allowed. */
+ src->min_region_sz = 4096;
+ KUNIT_EXPECT_EQ(test, damon_commit_ctx(dst, src), 0);
+ src->min_region_sz = 4095;
+ KUNIT_EXPECT_EQ(test, damon_commit_ctx(dst, src), -EINVAL);
+ damon_destroy_ctx(src);
+ damon_destroy_ctx(dst);
+}
+
static void damos_test_filter_out(struct kunit *test)
{
struct damon_target *t;
@@ -1316,6 +1337,7 @@ static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damos_test_commit_pageout),
KUNIT_CASE(damos_test_commit_migrate_hot),
KUNIT_CASE(damon_test_commit_target_regions),
+ KUNIT_CASE(damon_test_commit_ctx),
KUNIT_CASE(damos_test_filter_out),
KUNIT_CASE(damon_test_feed_loop_next_input),
KUNIT_CASE(damon_test_set_filters_default_reject),
--
2.47.3
next prev parent reply other threads:[~2026-03-07 19:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 19:42 [PATCH 0/2] mm/damon: test and document power-of-2 min_region_sz requirement SeongJae Park
2026-03-07 19:42 ` SeongJae Park [this message]
2026-03-07 19:42 ` [PATCH 2/2] Docs/mm/damon/design: document the power-of-two limitation for addr_unit 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=20260307194222.202075-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.