public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/damon: test and document power-of-2 min_region_sz requirement
@ 2026-03-07 19:42 SeongJae Park
  2026-03-07 19:42 ` [PATCH 1/2] mm/damon/tests/core-kunit: add a test for damon_commit_ctx() SeongJae Park
  2026-03-07 19:42 ` [PATCH 2/2] Docs/mm/damon/design: document the power-of-two limitation for addr_unit SeongJae Park
  0 siblings, 2 replies; 3+ messages in thread
From: SeongJae Park @ 2026-03-07 19:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Liam R. Howlett, Brendan Higgins, David Gow,
	David Hildenbrand, Jonathan Corbet, Lorenzo Stoakes, Michal Hocko,
	Mike Rapoport, Shuah Khan, Suren Baghdasaryan, Vlastimil Babka,
	damon, kunit-dev, linux-doc, linux-kernel, linux-kselftest,
	linux-mm

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.

SeongJae Park (2):
  mm/damon/tests/core-kunit: add a test for damon_commit_ctx()
  Docs/mm/damon/design: document the power-of-two limitation for
    addr_unit

 Documentation/mm/damon/design.rst |  2 ++
 mm/damon/tests/core-kunit.h       | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)


base-commit: 4380f0b6370ead5000b8d155b25a86cb59d68c06
-- 
2.47.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] mm/damon/tests/core-kunit: add a test for damon_commit_ctx()
  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
  2026-03-07 19:42 ` [PATCH 2/2] Docs/mm/damon/design: document the power-of-two limitation for addr_unit SeongJae Park
  1 sibling, 0 replies; 3+ messages in thread
From: SeongJae Park @ 2026-03-07 19:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Brendan Higgins, David Gow, damon, kunit-dev,
	linux-kernel, linux-kselftest, linux-mm

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Docs/mm/damon/design: document the power-of-two limitation for addr_unit
  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 ` [PATCH 1/2] mm/damon/tests/core-kunit: add a test for damon_commit_ctx() SeongJae Park
@ 2026-03-07 19:42 ` SeongJae Park
  1 sibling, 0 replies; 3+ messages in thread
From: SeongJae Park @ 2026-03-07 19:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Liam R. Howlett, David Hildenbrand,
	Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
	Shuah Khan, Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
	linux-kernel, linux-mm

The min_region_sz is set as max(DAMON_MIN_REGION_SZ / addr_unit, 1).
DAMON_MIN_REGION_SZ is the same to PAGE_SIZE, and addr_unit is what the
user can arbitrarily set.  Commit c80f46ac228b ("mm/damon/core: disallow
non-power of two min_region_sz") made min_region_sz to always be a power
of two.  Hence, addr_unit should be a power of two when it is smaller
than PAGE_SIZE.  While 'addr_unit' is a user-exposed parameter, the rule
is not documented.  This can confuse users.  Specifically, if the user
sets addr_unit as a value that is smaller than PAGE_SIZE and not a power
of two, the setup will explicitly fail.

Document the rule on the design document.  Usage documents reference the
design document for detail, so updating only the design document should
suffice.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 Documentation/mm/damon/design.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 28d932ceaf7ed..29fff20b3c2a9 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -150,6 +150,8 @@ address on the given address space.  Support of ``address unit`` parameter is
 up to each operations set implementation.  ``paddr`` is the only operations set
 implementation that supports the parameter.
 
+If the value is smaller than ``PAGE_SIZE``, only a power of two should be used.
+
 .. _damon_core_logic:
 
 Core Logics
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-07 19:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/2] mm/damon/tests/core-kunit: add a test for damon_commit_ctx() SeongJae Park
2026-03-07 19:42 ` [PATCH 2/2] Docs/mm/damon/design: document the power-of-two limitation for addr_unit SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox