On Fri, 12 Jun 2026 02:06:51 +0530 Sailesh Nandanavanam
<[email protected]> wrote:
> Hello SeongJae,
>
> Noted on inline replies - I'll follow that format from the next response.
>
> Following up on this thread with progress.
>
> As discussed, I dropped the userspace selftest approach since it
> cannot reliably trigger the microsecond-wide race window.
>
> I wrote a KUnit test instead, added to mm/damon/tests/core-kunit.h:
>
> - Creates a damon_ctx
> - Sets ctx->walk_control_obsolete = true under walk_control_lock,
> simulating the state just before kdamond_fn() exits
I don't think you don't need to hold the lock, since this is just a unit test
and there should be no race for the test.
> - Calls damos_walk() and verifies it returns -ECANCELED immediately
>
> I built and ran this on a kernel with commit 33c3f6c2b48c
> ("mm/damon/core: fix damos_walk() vs kdamond_fn() exit race") present,
> and the test passes along with all other 28 existing damon KUnit
> tests:
>
> ok 29 damon_test_walk_control_obsolete
> # damon: pass:29 fail:0 skip:0 total:29
>
> Since walk_control_obsolete is a field introduced by this fix, a
> kernel with the fix reverted would not compile this test (the field
> would not exist). So the usual "fails before fix, passes after fix"
> verification does not apply the same way here - the test directly
> validates the new field/behavior introduced by the fix.
>
> If this approach looks reasonable, I plan to send v3 with this KUnit
> test (replacing the userspace selftest from v1/v2), along with the
> commit message format and other minor fixes from your earlier review.
Other than the trivial comment about locking, your plan soudns reasonable to
me. Looking forward to your next patch!
Thanks,
SJ
[...]