[PATCH 0/5] mm/damon: five misc fixups

0 views
Skip to first unread message

SJ Park

unread,
Jun 29, 2026, 10:55:46 AM (5 days ago) Jun 29
to Andrew Morton, SJ Park, Liam R. Howlett, Brendan Higgins, David Gow, David Hildenbrand, Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport, Shuah Khan, Suren Baghdasaryan, Vlastimil Babka, da...@lists.linux.dev, kuni...@googlegroups.com, linu...@vger.kernel.org, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
Five patches for miscellaneous DAMON fixups. Use better fit kernel
functions, cleanup/fixup documents, and add unit tests.

Below is a note that is better to drop from the final commit message.
The five patches were initially sent and revisioned by different
individuals. Each patch contains changelog on their commentary area.
The patches are curated into this series by SJ, for the convenience in
reposting.

Akinobu Mita (1):
mm/damon/core: use kvmalloc for target regions array

Asier Gutierrez (1):
samples/damon: Fix typos in Kconfig help text

Doehyun Baek (1):
Docs/{admin-guide,mm}/damon: fix DAMON documentation details

Philippe Laferriere (1):
mm/damon/stat: use secs_to_jiffies() instead of msecs_to_jiffies()

Sailesh Nandanavanam (1):
mm/damon/tests/core-kunit: add KUnit test for walk_control_obsolete
behavior

Documentation/admin-guide/mm/damon/usage.rst | 8 +++---
Documentation/mm/damon/design.rst | 12 ++++-----
mm/damon/core.c | 4 +--
mm/damon/stat.c | 2 +-
mm/damon/tests/core-kunit.h | 28 ++++++++++++++++++++
samples/damon/Kconfig | 2 +-
6 files changed, 42 insertions(+), 14 deletions(-)


base-commit: 58a53a487b7a86995fdfba07723fb8416fccf830
--
2.47.3

SJ Park

unread,
Jun 29, 2026, 10:55:49 AM (5 days ago) Jun 29
to Andrew Morton, Sailesh Nandanavanam, Brendan Higgins, David Gow, SJ Park, da...@lists.linux.dev, kuni...@googlegroups.com, linux-...@vger.kernel.org, linux-k...@vger.kernel.org, linu...@kvack.org
From: Sailesh Nandanavanam <saileshna...@gmail.com>

Add a KUnit test to verify that damos_walk() rejects
new requests when walk_control_obsolete is set.

Commit 33c3f6c2b48c ("mm/damon/core: fix damos_walk() vs
kdamond_fn() exit race") introduced walk_control_obsolete
to prevent a race condition where new requests could be
registered during kdamond shutdown and never handled.

This test simulates the shutdown condition by setting
walk_control_obsolete and verifies that damos_walk()
returns -ECANCELED immediately.

This validates the invariant introduced by the fix and
helps prevent regressions.

Link: https://patch.msgid.link/20260612062337.2459-...@gmail.com
Suggested-by: SJ Park <s...@kernel.org>
Signed-off-by: Sailesh Nandanavanam <saileshna...@gmail.com>
Reviewed-by: SJ Park <s...@kernel.org>
Signed-off-by: SJ Park <s...@kernel.org>
---
Changes from v3
- v3: https://lore.kernel.org/20260612062337.2459-...@gmail.com
- Collect R-b: from SJ.
- Rebase to latest mm-new.
Changes since v2
- v2: https://lore.kernel.org/20260524100258.36819-...@gmail.com
- Dropped the userspace selftest approach entirely. SJ tested
v2 100 times on a kernel with the fix reverted and it always
passed, confirming the microsecond-wide race window cannot be
reliably hit from userspace due to syscall overhead.
- Added a KUnit test for damos_walk() + walk_control_obsolete
instead, as suggested by SJ. This directly sets the
obsolete flag and verifies damos_walk() returns -ECANCELED
immediately, without timing dependency.
Changes since v1
- v1: https://lore.kernel.org/20260524091812.35283-...@gmail.com
- Addressed sashiko bot review comments (execute bit, threading,
dynamic sysfs path, OSError handling) - superseded by the v3
approach above.

mm/damon/tests/core-kunit.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index fcf7c7fadb5fe..c5f5124c3d1f4 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -1456,6 +1456,33 @@ static void damon_test_is_last_region(struct kunit *test)
damon_free_target(t);
}

+/*
+ * Verify that damos_walk() rejects new requests when
+ * walk_control_obsolete is set.
+ *
+ * This tests the invariant introduced by:
+ * commit 33c3f6c2b48c ("mm/damon/core: fix damos_walk() vs kdamond_fn() exit race")
+ */
+static void damon_test_walk_control_obsolete(struct kunit *test)
+{
+ struct damon_ctx *ctx;
+ struct damos_walk_control control = {};
+ int ret;
+
+ ctx = damon_new_ctx();
+ if (!ctx)
+ kunit_skip(test, "ctx alloc fail");
+
+ /* Simulate shutdown phase */
+ ctx->walk_control_obsolete = true;
+
+ ret = damos_walk(ctx, &control);
+
+ KUNIT_EXPECT_EQ(test, ret, -ECANCELED);
+
+ damon_destroy_ctx(ctx);
+}
+
static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damon_test_target),
KUNIT_CASE(damon_test_regions),
@@ -1485,6 +1512,7 @@ static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damon_test_set_filters_default_reject),
KUNIT_CASE(damon_test_apply_min_nr_regions),
KUNIT_CASE(damon_test_is_last_region),
+ KUNIT_CASE(damon_test_walk_control_obsolete),
{},
};

--
2.47.3
Reply all
Reply to author
Forward
0 new messages