* [PATCH 0/5] mm/damon: five misc fixups
@ 2026-06-29 14:55 SJ Park
2026-06-29 14:55 ` [PATCH 5/5] mm/damon/tests/core-kunit: add KUnit test for walk_control_obsolete behavior SJ Park
0 siblings, 1 reply; 2+ messages in thread
From: SJ Park @ 2026-06-29 14:55 UTC (permalink / raw)
To: Andrew Morton
Cc: 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,
damon, kunit-dev, linux-doc, linux-kernel, linux-kselftest,
linux-mm
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
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 5/5] mm/damon/tests/core-kunit: add KUnit test for walk_control_obsolete behavior
2026-06-29 14:55 [PATCH 0/5] mm/damon: five misc fixups SJ Park
@ 2026-06-29 14:55 ` SJ Park
0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-06-29 14:55 UTC (permalink / raw)
To: Andrew Morton
Cc: Sailesh Nandanavanam, Brendan Higgins, David Gow, SJ Park, damon,
kunit-dev, linux-kernel, linux-kselftest, linux-mm
From: Sailesh Nandanavanam <saileshnandanavanam@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-1-saileshnandanavanam@gmail.com
Suggested-by: SJ Park <sj@kernel.org>
Signed-off-by: Sailesh Nandanavanam <saileshnandanavanam@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v3
- v3: https://lore.kernel.org/20260612062337.2459-1-saileshnandanavanam@gmail.com
- Collect R-b: from SJ.
- Rebase to latest mm-new.
Changes since v2
- v2: https://lore.kernel.org/20260524100258.36819-1-saileshnandanavanam@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-1-saileshnandanavanam@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-29 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-29 14:55 [PATCH 0/5] mm/damon: five misc fixups SJ Park
2026-06-29 14:55 ` [PATCH 5/5] mm/damon/tests/core-kunit: add KUnit test for walk_control_obsolete behavior SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox