mm/damon/tests/core-kunit: add test for damon_call() with repeat control
Subsystems (2)
PATCH 2/2 mm/damon/tests/core-kunit: add test for damon_call() with repeat control
When call_controls_obsolete is unset and damon_call_control->repeat is set, damon_call() should queue the request and return 0 immediately without waiting for kdamond to handle it. Add a kunit test for that.
--- mm/damon/tests/core-kunit.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
mm/damon/tests/core-kunit.h +25 -0
@@ -2499,6 +2499,30 @@ static void damon_test_call_controls_obsolete(struct kunit *test)damon_destroy_ctx (ctx); } +static void damon_test_call_repeat (struct kunit *test) +{ +struct damon_ctx *ctx; +struct damon_call_control control = {}; +int ret; + + ctx =damon_new_ctx (); + +if (!ctx) +kunit_skip (test,"ctx alloc fail" ); + + ctx->call_controls_obsolete = false; + control.repeat = true; + + ret =damon_call (ctx, &control); + +KUNIT_EXPECT_EQ (test, ret,0 ); +KUNIT_EXPECT_FALSE (test,list_empty (&ctx->call_controls)); +KUNIT_EXPECT_PTR_EQ (test, ctx->call_controls.next, &control.list); + +list_del (&control.list); +damon_destroy_ctx (ctx); +} +static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_target),KUNIT_CASE (damon_test_regions),
@@ -2544,6 +2568,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damos_test_esz_goal_temporal),KUNIT_CASE (damon_test_last_region_quota_reset),KUNIT_CASE (damon_test_call_controls_obsolete), + KUNIT_CASE(damon_test_call_repeat), {}, };
Signature · 1 line
2.34.1
SJ Park
maintainerQuoted 3 lines · On Tue, 17 Nov 2026 23:18:34 +0530 Sailesh Nandanavanam…
When
call_controls_obsoleteis unset anddamon_call_control->repeatis set,damon_call()should queue the request and return 0 immediately without waiting for kdamond to handle it. Add a kunit test for that.
Apparently this patch was meant to be sent as a part of a series with another patch [1] but individually sent by a setup failure. As a result, this patch is not reviewed by Sashiko. Could you please repost as the series?
Quoted 23 lines
Signed-off-by Sailesh Nandanavanam <[email protected]>--- mm/damon/tests/core-kunit.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)mm/damon/tests/core-kunit.h +9
-0@@ -2499,6 +2499,30 @@ static void damon_test_call_controls_obsolete(struct kunit *test)damon_destroy_ctx (ctx); } +static void damon_test_call_repeat (struct kunit *test) +{ +struct damon_ctx *ctx; +struct damon_call_control control = {}; +int ret; + + ctx =damon_new_ctx (); + +if (!ctx)
mm/damon/tests/core-kunit.h static void damon_test_call_controls_obsolete(struct kunit *test) · line 2520
Quoted 10 lines
mm/damon/tests/core-kunit.h +10
-0+kunit_skip (test,"ctx alloc fail" ); + + ctx->call_controls_obsolete = false; + control.repeat = true; + + ret =damon_call (ctx, &control); + +KUNIT_EXPECT_EQ (test, ret,0 ); +KUNIT_EXPECT_FALSE (test,list_empty (&ctx->call_controls)); +KUNIT_EXPECT_PTR_EQ (test, ctx->call_controls.next, &control.list);
I think the above last two expects are somewhat too much implementation detail. I don't think we are promising those list status. I'd prefer dropping those.
mm/damon/tests/core-kunit.h static void damon_test_call_controls_obsolete(struct kunit *test) · line 2522
Quoted 2 lines
mm/damon/tests/core-kunit.h +2
-0+ +list_del (&control.list);
Can anything leak or corrupted if we don't call list_del() here?
mm/damon/tests/core-kunit.h static struct kunit_case damon_test_cases[] = { · line 2571
Quoted 11 lines
mm/damon/tests/core-kunit.h +4
-0+damon_destroy_ctx (ctx); +} +static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_target),KUNIT_CASE (damon_test_regions),@@ -2544,6 +2568,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damos_test_esz_goal_temporal),KUNIT_CASE (damon_test_last_region_quota_reset),KUNIT_CASE (damon_test_call_controls_obsolete), + KUNIT_CASE(damon_test_call_repeat),
Could we merge the above two tests into one, say, damon_test_call()?
[1] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]
From: Sailesh Nandanavanam <[email protected]>
Quoted 2 lines · On Wed, 18 Nov 2026 SJ Park <[email protected]> wrote:
I think the above last two expects are somewhat too much implementation detail. I don't think we are promising those list status. I'd prefer dropping those.
Agreed, dropping both list assertions.
Quoted 1 line
Can anything leak or corrupted if we don't call
list_del()here?
No. The control is stack-allocated and damon_destroy_ctx() does not touch call_controls, so nothing is leaked or accessed afterwards. Will drop the list_del().
Quoted 1 line
Could we merge the above two tests into one, say,
damon_test_call()?
Will merge them into damon_test_call() and send v2 as a single patch.
Quoted 3 lines
Apparently this patch was meant to be sent as a part of a series with another patch [1] but individually sent by a setup failure. As a result, this patch is not reviewed by Sashiko. Could you please repost as the series?
Sorry for the mess. Since the two tests will be merged, v2 will be a single patch, so Sashiko will review it.
Thanks,
Sailesh