* [PATCH 3/4] selftests/damon/damos_quota: skip the last sample when counting exceeds
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
@ 2026-11-24 15:30 ` SJ Park
2026-11-24 15:30 ` [PATCH 4/4] mm/damon/tests/core-kunit: add test for damon_call() SJ Park
1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-11-24 15:30 UTC (permalink / raw)
To: Andrew Morton
Cc: Aveline Noir, SJ Park, Shuah Khan, Shuah Khan, damon,
linux-kselftest, linux-mm
From: Aveline Noir <jm5905938@gmail.com>
damos_quota.py expects qt_exceeds to be increased for every sample whose
tried_bytes equals the quota. The kernel increases it only when the next
quota window starts, so the last full window may still be pending when
the workload exits. The test then fails with an expected count one
higher than the actual one, e.g., 15 < 16.
Do not count the last sample. Also drop the sorting of the samples, so
that the last one is the latest.
Cc: Shuah Khan <shuah@kernel.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261117-fix-damon-quota-selftest-20261117-v1-1-c65d687d3def@gmail.com
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
tools/testing/selftests/damon/damos_quota.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py
index 879115a499bf8..bdfd22f000795 100755
--- a/tools/testing/selftests/damon/damos_quota.py
+++ b/tools/testing/selftests/damon/damos_quota.py
@@ -53,15 +53,16 @@ def main():
wss_collected.append(scheme.tried_bytes)
nr_quota_exceeds = scheme.stats.qt_exceeds
- wss_collected.sort()
nr_expected_quota_exceeds = 0
- for wss in wss_collected:
+ for idx, wss in enumerate(wss_collected):
if wss > sz_quota:
print('quota is not kept: %s > %s' % (wss, sz_quota))
print('collected samples are as below')
print('\n'.join(['%d' % wss for wss in wss_collected]))
exit(1)
- if wss == sz_quota:
+ # qt_exceeds is updated when the next quota window starts, so skip
+ # the last sample, whose window may still be pending.
+ if wss == sz_quota and idx < len(wss_collected) - 1:
nr_expected_quota_exceeds += 1
if nr_quota_exceeds < nr_expected_quota_exceeds:
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 4/4] mm/damon/tests/core-kunit: add test for damon_call()
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
2026-11-24 15:30 ` [PATCH 3/4] selftests/damon/damos_quota: skip the last sample when counting exceeds SJ Park
@ 2026-11-24 15:30 ` SJ Park
1 sibling, 0 replies; 3+ messages in thread
From: SJ Park @ 2026-11-24 15:30 UTC (permalink / raw)
To: Andrew Morton
Cc: Sailesh Nandanavanam, Brendan Higgins, David Gow, SJ Park, damon,
kunit-dev, linux-kselftest, linux-mm, Aveline Noir
From: Sailesh Nandanavanam <saileshnandanavanam@gmail.com>
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 <saileshnandanavanam@gmail.com>
Tested-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread