Skip to contentSkip to conversation

mm/damon/tests/core-kunit: add test for damon_call() on obsolete ctx

PATCH In review Sailesh Nandanavanam 3 participants 3 messages Nov 17 – Nov 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/damon/tests/core-kunit: add test for damon_call() on obsolete ctx

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. Add a kunit test for that.

---
 mm/damon/tests/core-kunit.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
mm/damon/tests/core-kunit.h +19 -0
index 43e2f950f8ff..13315291f69f 100644
@@ -2481,6 +2481,24 @@ static void damon_test_last_region_quota_reset(struct kunit *test)
 	damon_free_target(t);
 }
 
+static void damon_test_call_controls_obsolete(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);
+
+	damon_destroy_ctx(ctx);
+}
+
 static struct kunit_case damon_test_cases[] = {
 	KUNIT_CASE(damon_test_target),
 	KUNIT_CASE(damon_test_regions),
@@ -2525,6 +2543,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_controls_obsolete),
 	{},
 };
 

base-commit: 72e1cd73734bc4d52affbf7896389bf3814bcf9d

Signature · 1 line
2.34.1
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 6 lines

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. Add a kunit test for that.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Sailesh Nandanavanam
Quoted 4 lines · On Tue, 17 Nov 2026 22:52:19 +0530 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. Add a kunit test for that.

Please check my suggestions on the reply [1] to your another patch.

[1] https://lore.kernel.org/[email protected]

Thanks,
SJ

[...]