From: Sailesh Nandanavanam A newly allocated damon_ctx has call_controls_obsolete set, meaning no kdamond is available to handle call requests. damon_call() should return -ECANCELED in that case instead of queueing the request and waiting forever. When call_controls_obsolete is unset and damon_call_control->repeat is set, damon_call() should return 0 without waiting for kdamond. Add a kunit test for the two cases. Signed-off-by: Sailesh Nandanavanam Tested-by: Aveline Noir Reviewed-by: Aveline Noir Reviewed-by: SJ Park Signed-off-by: SJ Park --- Changes from v2 - v2: https://lore.kernel.org/20261118063755.37749-1-saileshnandanavanam@gmail.com - Collect R-b: from SJ. - Rebase to the latest mm-new. Changes from v1 (https://lore.kernel.org/20261117172219.26725-1-saileshnandanavanam@gmail.com, https://lore.kernel.org/20261117174834.29182-1-saileshnandanavanam@gmail.com) - Merge the two tests into damon_test_call(). - Drop the list_empty()/call_controls.next expectations. - Drop list_del() on the stack-allocated control. - Post as a single patch. 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 a27545602680a..4446574a35652 100644 --- a/mm/damon/tests/core-kunit.h +++ b/mm/damon/tests/core-kunit.h @@ -2724,6 +2724,27 @@ static void damos_test_sz_ops_filter_passed_last(struct kunit *test) damon_destroy_ctx(c); } +static void damon_test_call(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"); + + ret = damon_call(ctx, &control); + KUNIT_EXPECT_EQ(test, ret, -ECANCELED); + + ctx->call_controls_obsolete = false; + control.repeat = true; + ret = damon_call(ctx, &control); + KUNIT_EXPECT_EQ(test, ret, 0); + + damon_destroy_ctx(ctx); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -2771,6 +2792,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(damos_test_sz_ops_filter_passed_last), + KUNIT_CASE(damon_test_call), {}, }; -- 2.47.3