mm/damon/tests/core-kunit: add test for damon_call()
Subsystems (2)
PATCH v2 1/1 mm/damon/tests/core-kunit: add test for damon_call()
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.
---
Changes from v1
(https://lore.kernel.org/[email protected],
https://lore.kernel.org/[email protected])
- 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(+)
mm/damon/tests/core-kunit.h +22 -0
@@ -2481,6 +2481,27 @@ static void damon_test_last_region_quota_reset(struct kunit *test)damon_free_target (t); } +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),
@@ -2525,6 +2546,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_rand),KUNIT_CASE (damos_test_esz_goal_temporal),KUNIT_CASE (damon_test_last_region_quota_reset), + KUNIT_CASE(damon_test_call), {}, };
base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca
Signature · 1 line
2.34.1
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 8 lines
A newly allocated
damon_ctxhascall_controls_obsoleteset, meaning no kdamond is available to handle call requests.damon_call()should return-ECANCELEDin that case instead of queueing the request and waiting forever. Whencall_controls_obsoleteis unset anddamon_call_control->repeatis set,damon_call()should return 0 without waiting for kdamond. Add a kunit test for the two cases.Signed-off-by Sailesh Nandanavanam <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi Sailesh,
Quoted 1 line · On Wed, 18 Nov 2026 12:07:55 +0530 Sailesh Nandanavanam wrote:
Add a kunit test for the two cases.
Make sense. Thanks :)
Tested v2 on x86-64 QEMU with v7.4-rc3 as the base. All DAMON KUnit tests passed.
Thanks,
Aveline Noir