mm/damon/tests: add KUnit coverage for age_ms filters
Subsystems (3)
SJ Park
maintainerv3 cover mm/damon/tests: add KUnit coverage for age_ms filters
From: Jason Angelov <[email protected]>
The DAMON core tests do not cover DAMOS_FILTER_TYPE_AGE_MS. Add tests for committing valid and invalid age ranges, identifying the filter as core-handled, and matching ages at and outside the range boundaries.
Region age is counted in aggregation intervals, but age_ms filter bounds are in milliseconds. The interval-change test checks filter matching after both increasing and decreasing the aggregation interval.
Changes from v2
- v2: https://lore.kernel.org/[email protected]
- Collect R-b: from Aveline and SJ.
Changes in v2:
- Fix commit-message formatting, line wrapping, and comments.
- Set age and interval inputs directly in patch 3.
- Add SJ's Reviewed-by tags to patches 1 and 2.
- Link to v1: https://lore.kernel.org/r/[email protected]
Jason Angelov (3):
mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in
damos_test_commit_filter()
mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in
damos_filter_for_ops()
mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS interval
changes
mm/damon/tests/core-kunit.h | 93 +++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)
base-commit: 5247761933577a245d262c55994032b86cbec2d1
Signature · 1 line
2.47.3
SJ Park
maintainerPATCH v3 1/3 mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_test_commit_filter()
From: Jason Angelov <[email protected]>
Add kunit tests that commit DAMOS core filter type DAMOS_FILTER_TYPE_AGE_MS.
--- mm/damon/tests/core-kunit.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
mm/damon/tests/core-kunit.h +20 -0
@@ -1271,6 +1271,10 @@ static void damos_test_commit_filter_for(struct kunit *test,KUNIT_EXPECT_EQ (test, dst->matching, src->matching);KUNIT_EXPECT_EQ (test, dst->allow, src->allow);switch (src->type) { +case DAMOS_FILTER_TYPE_AGE_MS : +KUNIT_EXPECT_EQ (test, dst->range_min, src->range_min); +KUNIT_EXPECT_EQ (test, dst->range_max, src->range_max); +break ;case DAMOS_FILTER_TYPE_MEMCG :KUNIT_EXPECT_EQ (test, dst->memcg_id, src->memcg_id);break ;
@@ -1304,6 +1308,22 @@ static void damos_test_commit_filter(struct kunit *test) .allow = false, }; +damos_test_commit_filter_for (test, &dst, + &(struct damos_filter ){ + .type =DAMOS_FILTER_TYPE_AGE_MS , + .matching = true, + .allow = true, + .range_min =36 , + .range_max =14 + }, true); +damos_test_commit_filter_for (test, &dst, + &(struct damos_filter ){ + .type =DAMOS_FILTER_TYPE_AGE_MS , + .matching = true, + .allow = true, + .range_min =14 , + .range_max =36 + }, false); damos_test_commit_filter_for(test, &dst, &(struct damos_filter){ .type = DAMOS_FILTER_TYPE_ANON,
Signature · 1 line
2.47.3
+ mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter.patch added to mm-new branch
The patch titled Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_test_commit_filter() has been added to the -mm mm-new branch. Its filename is…
The patch titled
Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_test_commit_filter()
has been added to the -mm mm-new branch. Its filename is
mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Jason Angelov <[email protected]>
Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_test_commit_filter()
Date: Mon, 23 Nov 2026 07:09:25 -0800
Patch series "mm/damon/tests: add KUnit coverage for age_ms filters", v3.
The DAMON core tests do not cover DAMOS_FILTER_TYPE_AGE_MS. Add tests for committing valid and invalid age ranges, identifying the filter as core-handled, and matching ages at and outside the range boundaries.
Region age is counted in aggregation intervals, but age_ms filter bounds are in milliseconds. The interval-change test checks filter matching after both increasing and decreasing the aggregation interval.
This patch (of 3):
Add kunit tests that commit DAMOS core filter type DAMOS_FILTER_TYPE_AGE_MS.
mm/damon/tests/core-kunit.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
mm/damon/tests/core-kunit.h renamed from mm/damon/tests/core-kunit.h~mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter +20 -0
@@ -1271,6 +1271,10 @@ static void damos_test_commit_filter_forKUNIT_EXPECT_EQ (test, dst->matching, src->matching);KUNIT_EXPECT_EQ (test, dst->allow, src->allow);switch (src->type) { +case DAMOS_FILTER_TYPE_AGE_MS : +KUNIT_EXPECT_EQ (test, dst->range_min, src->range_min); +KUNIT_EXPECT_EQ (test, dst->range_max, src->range_max); +break ;case DAMOS_FILTER_TYPE_MEMCG :KUNIT_EXPECT_EQ (test, dst->memcg_id, src->memcg_id);break ;
@@ -1306,6 +1310,22 @@ static void damos_test_commit_filter(strdamos_test_commit_filter_for (test, &dst, &(struct damos_filter ){ + .type =DAMOS_FILTER_TYPE_AGE_MS , + .matching = true, + .allow = true, + .range_min =36 , + .range_max =14 + }, true); +damos_test_commit_filter_for (test, &dst, + &(struct damos_filter ){ + .type =DAMOS_FILTER_TYPE_AGE_MS , + .matching = true, + .allow = true, + .range_min =14 , + .range_max =36 + }, false); + damos_test_commit_filter_for(test, &dst, + &(struct damos_filter){ .type = DAMOS_FILTER_TYPE_ANON, .matching = true, .allow = true,
_
Patches currently in -mm which might be from [email protected] are
mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter.patch mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops.patch mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes.patch
SJ Park
maintainerPATCH v3 2/3 mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_filter_for_ops()
In reply to SJ ParkFrom: Jason Angelov <[email protected]>
DAMOS_FILTER_TYPE_AGE_MS is core filter, not ops filter. Add kunit test covering this rejection.
--- mm/damon/tests/core-kunit.h | 7 +++++++ 1 file changed, 7 insertions(+)
mm/damon/tests/core-kunit.h +7 -0
@@ -1832,6 +1832,12 @@ static void damon_test_valid_probe_params(struct kunit *test)damon_destroy_ctx (ctx); } +static void damos_test_age_ms_filter_is_core (struct kunit *test) +{ +KUNIT_EXPECT_FALSE (test, +damos_filter_for_ops (DAMOS_FILTER_TYPE_AGE_MS )); +} +static void damos_test_filter_out (struct kunit *test) {struct damon_target *t;
@@ -2593,6 +2599,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_commit_ctx),KUNIT_CASE (damon_test_commit_ctx_keeps_quota),KUNIT_CASE (damon_test_valid_probe_params), +KUNIT_CASE (damos_test_age_ms_filter_is_core),KUNIT_CASE (damos_test_filter_out),KUNIT_CASE (damos_test_apply_scheme_filtered_sz), KUNIT_CASE(damos_test_apply_scheme_filter_sz_unchanged),
Signature · 1 line
2.47.3
+ mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops.patch added to mm-new branch
The patch titled Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_filter_for_ops() has been added to the -mm mm-new branch. Its filename is…
The patch titled
Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_filter_for_ops()
has been added to the -mm mm-new branch. Its filename is
mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Jason Angelov <[email protected]>
Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS in damos_filter_for_ops()
Date: Mon, 23 Nov 2026 07:09:26 -0800
DAMOS_FILTER_TYPE_AGE_MS is core filter, not ops filter. Add kunit test covering this rejection.
mm/damon/tests/core-kunit.h | 7 +++++++ 1 file changed, 7 insertions(+)
mm/damon/tests/core-kunit.h renamed from mm/damon/tests/core-kunit.h~mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops +7 -0
@@ -1832,6 +1832,12 @@ static void damon_test_valid_probe_paramdamon_destroy_ctx (ctx); } +static void damos_test_age_ms_filter_is_core (struct kunit *test) +{ +KUNIT_EXPECT_FALSE (test, +damos_filter_for_ops (DAMOS_FILTER_TYPE_AGE_MS )); +} +static void damos_test_filter_out (struct kunit *test) {struct damon_target *t;
@@ -2593,6 +2599,7 @@ static struct kunit_case damon_test_caseKUNIT_CASE (damon_test_commit_ctx),KUNIT_CASE (damon_test_commit_ctx_keeps_quota),KUNIT_CASE (damon_test_valid_probe_params), +KUNIT_CASE (damos_test_age_ms_filter_is_core),KUNIT_CASE (damos_test_filter_out),KUNIT_CASE (damos_test_apply_scheme_filtered_sz), KUNIT_CASE(damos_test_apply_scheme_filter_sz_unchanged),
_
Patches currently in -mm which might be from [email protected] are
mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter.patch mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops.patch mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes.patch
SJ Park
maintainerPATCH v3 3/3 mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS interval changes
In reply to SJ ParkFrom: Jason Angelov <[email protected]>
DAMOS_FILTER_TYPE_AGE_MS defines an inclusive range for age in milliseconds to filter for target regions. Aggregation interval can be changed by users or intervals auto-tuning features.
Add a kunit test for each:
- convert region age to milliseconds, correct behavior at boundaries for defined filter range
- DAMOS_FILTER_TYPE_AGE_MS filter keeps correct behavior even when aggregation interval changes
--- mm/damon/tests/core-kunit.h | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
mm/damon/tests/core-kunit.h +66 -0
@@ -1838,6 +1838,71 @@ static void damos_test_age_ms_filter_is_core(struct kunit *test) damos_filter_for_ops(DAMOS_FILTER_TYPE_AGE_MS)); } +static void damos_test_age_ms_filter_interval_changes (struct kunit *test) +{ +struct damos_filter filter = { + .type =DAMOS_FILTER_TYPE_AGE_MS , + .matching = true, + .range_min =200 , + .range_max =400 , + }; +struct damon_ctx *ctx; +struct damon_target *t; +struct damon_region *r; +int err; + + ctx =damon_new_ctx (); +if (!ctx) +kunit_skip (test,"ctx alloc fail" ); + t =damon_new_target (); +if (!t) { +damon_destroy_ctx (ctx); +kunit_skip (test,"target alloc fail" ); + } +damon_add_target (ctx, t); + r =damon_new_region (0 ,DAMON_MIN_REGION_SZ ); +if (!r) { +damon_destroy_ctx (ctx); +kunit_skip (test,"region alloc fail" ); + } +damon_add_region (r, t); + ctx->attrs.aggr_interval =100000 ; + +/* An age of 100 ms is below the 200 ms lower bound. */ + r->age =1 ; +KUNIT_EXPECT_FALSE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* An age of 200 ms matches the inclusive lower bound. */ + r->age =2 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* At a 200 ms interval, age 1 matches the lower bound. */ + ctx->attrs.aggr_interval =200000 ; + r->age =1 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* An age of 400 ms matches the inclusive upper bound. */ + r->age =2 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* At a 50 ms interval, age 8 matches the upper bound. */ + ctx->attrs.aggr_interval =50000 ; + r->age =8 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* An age of 450 ms exceeds the 400 ms upper bound. */ + r->age =9 ; +KUNIT_EXPECT_FALSE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +damon_destroy_ctx (ctx); +} +static void damos_test_filter_out (struct kunit *test) {struct damon_target *t;
@@ -2600,6 +2665,7 @@ static struct kunit_case damon_test_cases[] = {KUNIT_CASE (damon_test_commit_ctx_keeps_quota),KUNIT_CASE (damon_test_valid_probe_params),KUNIT_CASE (damos_test_age_ms_filter_is_core), +KUNIT_CASE (damos_test_age_ms_filter_interval_changes),KUNIT_CASE (damos_test_filter_out),KUNIT_CASE (damos_test_apply_scheme_filtered_sz), KUNIT_CASE(damos_test_apply_scheme_filter_sz_unchanged),
Signature · 1 line
2.47.3
+ mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes.patch added to mm-new branch
The patch titled Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS interval changes has been added to the -mm mm-new branch. Its filename is…
The patch titled
Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS interval changes
has been added to the -mm mm-new branch. Its filename is
mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Jason Angelov <[email protected]>
Subject: mm/damon/tests/core-kunit: test DAMOS_FILTER_TYPE_AGE_MS interval changes
Date: Mon, 23 Nov 2026 07:09:27 -0800
DAMOS_FILTER_TYPE_AGE_MS defines an inclusive range for age in milliseconds to filter for target regions. Aggregation interval can be changed by users or intervals auto-tuning features.
Add a kunit test for each:
- convert region age to milliseconds, correct behavior at boundaries for defined filter range
- DAMOS_FILTER_TYPE_AGE_MS filter keeps correct behavior even when aggregation interval changes
mm/damon/tests/core-kunit.h | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
mm/damon/tests/core-kunit.h renamed from mm/damon/tests/core-kunit.h~mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes +66 -0
@@ -1838,6 +1838,71 @@ static void damos_test_age_ms_filter_is_ damos_filter_for_ops(DAMOS_FILTER_TYPE_AGE_MS)); } +static void damos_test_age_ms_filter_interval_changes (struct kunit *test) +{ +struct damos_filter filter = { + .type =DAMOS_FILTER_TYPE_AGE_MS , + .matching = true, + .range_min =200 , + .range_max =400 , + }; +struct damon_ctx *ctx; +struct damon_target *t; +struct damon_region *r; +int err; + + ctx =damon_new_ctx (); +if (!ctx) +kunit_skip (test,"ctx alloc fail" ); + t =damon_new_target (); +if (!t) { +damon_destroy_ctx (ctx); +kunit_skip (test,"target alloc fail" ); + } +damon_add_target (ctx, t); + r =damon_new_region (0 ,DAMON_MIN_REGION_SZ ); +if (!r) { +damon_destroy_ctx (ctx); +kunit_skip (test,"region alloc fail" ); + } +damon_add_region (r, t); + ctx->attrs.aggr_interval =100000 ; + +/* An age of 100 ms is below the 200 ms lower bound. */ + r->age =1 ; +KUNIT_EXPECT_FALSE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* An age of 200 ms matches the inclusive lower bound. */ + r->age =2 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* At a 200 ms interval, age 1 matches the lower bound. */ + ctx->attrs.aggr_interval =200000 ; + r->age =1 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* An age of 400 ms matches the inclusive upper bound. */ + r->age =2 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* At a 50 ms interval, age 8 matches the upper bound. */ + ctx->attrs.aggr_interval =50000 ; + r->age =8 ; +KUNIT_EXPECT_TRUE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +/* An age of 450 ms exceeds the 400 ms upper bound. */ + r->age =9 ; +KUNIT_EXPECT_FALSE (test,damos_filter_match (ctx, t, r, &filter, + ctx->min_region_sz, &err)); + +damon_destroy_ctx (ctx); +} +static void damos_test_filter_out (struct kunit *test) {struct damon_target *t;
@@ -2600,6 +2665,7 @@ static struct kunit_case damon_test_caseKUNIT_CASE (damon_test_commit_ctx_keeps_quota),KUNIT_CASE (damon_test_valid_probe_params),KUNIT_CASE (damos_test_age_ms_filter_is_core), +KUNIT_CASE (damos_test_age_ms_filter_interval_changes),KUNIT_CASE (damos_test_filter_out),KUNIT_CASE (damos_test_apply_scheme_filtered_sz), KUNIT_CASE(damos_test_apply_scheme_filter_sz_unchanged),
_
Patches currently in -mm which might be from [email protected] are
mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_test_commit_filter.patch mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-in-damos_filter_for_ops.patch mm-damon-tests-core-kunit-test-damos_filter_type_age_ms-interval-changes.patch
[email protected]
AI reviewSashiko has reviewed this 3-patch series and found no issues.
Sashiko has reviewed this 3-patch series and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]