summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2026-03-07 22:42:20 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-04-05 23:53:21 +0300
commita260de7d45ea9144645748b1c54896dea6f79655 (patch)
tree7500084b2cc23399864e6b30606ab9a31b013c5f
parent300252ebb116e8f9908a5f52203984b1bc15cc78 (diff)
downloadlinux-a260de7d45ea9144645748b1c54896dea6f79655.tar.xz
mm/damon/tests/core-kunit: add a test for damon_commit_ctx()
Patch series "mm/damon: test and document power-of-2 min_region_sz requirement". Since commit c80f46ac228b ("mm/damon/core: disallow non-power of two min_region_sz"), min_region_sz is always restricted to be a power of two. Add a kunit test to confirm the functionality. Also, the change adds a restriction to addr_unit parameter. Clarify it on the document. This patch (of 2): 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. Link: https://lkml.kernel.org/r/20260307194222.202075-2-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Brendan Higgins <brendan.higgins@linux.dev> Cc: David Gow <davidgow@google.com> Cc: David Hildenbrand <david@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes (Oracle) <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: SeongJae Park <sj@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/damon/tests/core-kunit.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index fcc1336b234c..2289f9e4610c 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -1057,6 +1057,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;
@@ -1313,6 +1334,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),