* [RFC PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method
@ 2026-12-01 14:52 SJ Park
2026-12-01 14:52 ` [RFC PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
0 siblings, 1 reply; 2+ messages in thread
From: SJ Park @ 2026-12-01 14:52 UTC (permalink / raw)
Cc: SJ Park, Andrew Morton, Brendan Higgins, David Gow,
Jonathan Corbet, Randy Dunlap, Shuah Khan, damon, kunit-dev,
linux-doc, linux-kselftest, linux-mm
DAMOS access pattern and core filters are treated as a primary and a
secondary target selection method, respectively. DAMOS target regions
are initially selected with the access pattern, and later evaluated for
the core filters only when needed, in the middle of lower level
operations. DAMOS quota goal type eligible_mem_bp is ignoring the core
filters.
There is no real reason to treat DAMOS core filters as a secondary
method, though. DAMOS stats treat core filter rejections the same to
access pattern-based rejections. The core filters are effectively
applied for every operation. The duplicated handling of the filters in
each operation only makes it easy to mistake.
Promote DAMOS core filters to a primary target selection method. Use it
in the central high level place that DAMOS access pattern is handled.
One consequence of this change is the behavioral change of
eligible_mem_bp DAMOS quota goal type. It was ignoring core filters.
This change makes it aware of core filters. It is difficult to imagine
real users that depend on the old behavior. And the new behavior is
more intuitive in my opinion.
Remove unit tests that were too duplicated and will fail after the
change, via patch 1. Make the promotion via patch 2. Clarify the
changed eligible_mem_bp behavior on the design document, via patch 3.
Changes from RFC
- RFC: https://lore.kernel.org/20261130152242.90137-1-sj@kernel.org
- Restore dasmos_test_apply_scheme_quota_sz().
- Rebase to the latest mm-new.
SJ Park (3):
mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
mm/damon/core: apply damos core filter in __damos_valid_target()
Docs/mm/damon/design: update node_eligible_mem_bp for changed behavior
Documentation/mm/damon/design.rst | 4 +-
mm/damon/core.c | 26 ++--
mm/damon/tests/core-kunit.h | 210 ------------------------------
3 files changed, 17 insertions(+), 223 deletions(-)
base-commit: 872ceec1e3caf227655a58f7407a9c8493dcf56f
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [RFC PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
2026-12-01 14:52 [RFC PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
@ 2026-12-01 14:52 ` SJ Park
0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-12-01 14:52 UTC (permalink / raw)
Cc: SJ Park, Andrew Morton, Brendan Higgins, David Gow, damon,
kunit-dev, linux-kselftest, linux-mm
Two kunit tests that were introduced by commit 1c3352282063
("mm/damon/tests/core-kunit: test the size charged for a filter-trimmed
region"), damos_test_apply_scheme_filter{ed_sz,_sz_unchanged}(), are
arguably doing duplicated tests. Those are testing core filter
functionality in damos_apply_scheme(), only because the filters are
applied in damos_apply_scheme(). But the core filter functionality is
already tested by damos_test_filter_out(). Remove the duplicated tests.
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/tests/core-kunit.h | 210 ------------------------------------
1 file changed, 210 deletions(-)
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 73c3bd6a9612..e7cef4792923 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -2007,214 +2007,6 @@ static unsigned long damos_test_apply_scheme_stub(struct damon_ctx *c,
return 0;
}
-static void damos_test_apply_scheme_filtered_sz(struct kunit *test)
-{
- struct damos_access_pattern pattern = {
- .min_sz_region = 0,
- .max_sz_region = ULONG_MAX,
- .min_nr_accesses = 0,
- .max_nr_accesses = UINT_MAX,
- .min_age_region = 0,
- .max_age_region = UINT_MAX,
- };
- unsigned long min_sz = DAMON_MIN_REGION_SZ;
- struct damos_watermarks wmarks = {};
- struct damos_quota quota = {};
- struct damon_ctx *c;
- struct damon_target *t;
- struct damon_region *r;
- struct damos_filter *f;
- struct damos *s;
-
- c = damon_new_ctx();
- if (!c)
- kunit_skip(test, "ctx alloc fail");
- c->ops.apply_scheme = damos_test_apply_scheme_stub;
-
- s = damon_new_scheme(&pattern, DAMOS_STAT, 0, "a, &wmarks,
- NUMA_NO_NODE);
- if (!s) {
- damon_destroy_ctx(c);
- kunit_skip(test, "scheme alloc fail");
- }
- damon_add_scheme(c, s);
-
- t = damon_new_target();
- if (!t) {
- damon_destroy_ctx(c);
- kunit_skip(test, "target alloc fail");
- }
- damon_add_target(c, t);
-
- f = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false);
- if (!f) {
- damon_destroy_ctx(c);
- kunit_skip(test, "filter alloc fail");
- }
- f->addr_range = (struct damon_addr_range){
- .start = 2 * min_sz,
- .end = 8 * min_sz
- };
- damos_add_filter(s, f);
- damos_set_filters_default_reject(s);
-
- /* reject filter, region starting before the range */
- r = damon_new_region(0, 4 * min_sz);
- if (!r) {
- damon_destroy_ctx(c);
- kunit_skip(test, "region alloc fail");
- }
- damon_add_region(r, t);
-
- damos_apply_scheme(c, t, r, s);
- KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2);
- KUNIT_EXPECT_EQ(test, r->ar.end, 2 * min_sz);
- KUNIT_EXPECT_EQ(test, s->stat.sz_tried, 2 * min_sz);
-
- if (damon_nr_regions(t) != 2)
- goto out;
- damon_destroy_region(damon_next_region(r), t);
- damon_destroy_region(r, t);
- s->stat = (struct damos_stat){};
-
- /* allow filter, region starting inside the range */
- f->allow = true;
- damos_set_filters_default_reject(s);
- r = damon_new_region(2 * min_sz, 10 * min_sz);
- if (!r) {
- damon_destroy_ctx(c);
- kunit_skip(test, "region alloc fail");
- }
- damon_add_region(r, t);
-
- damos_apply_scheme(c, t, r, s);
- KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2);
- KUNIT_EXPECT_EQ(test, r->ar.end, 8 * min_sz);
- KUNIT_EXPECT_EQ(test, s->stat.sz_tried, 6 * min_sz);
-
-out:
- damon_destroy_ctx(c);
-}
-
-static void damos_test_apply_scheme_filter_sz_unchanged(struct kunit *test)
-{
- struct damos_access_pattern pattern = {
- .min_sz_region = 0,
- .max_sz_region = ULONG_MAX,
- .min_nr_accesses = 0,
- .max_nr_accesses = UINT_MAX,
- .min_age_region = 0,
- .max_age_region = UINT_MAX,
- };
- unsigned long min_sz = DAMON_MIN_REGION_SZ;
- struct damos_watermarks wmarks = {};
- struct damos_quota quota = {};
- struct damos_filter *f, *f2;
- struct damon_ctx *c;
- struct damon_target *t;
- struct damon_region *r;
- struct damos *s;
-
- c = damon_new_ctx();
- if (!c)
- kunit_skip(test, "ctx alloc fail");
- c->ops.apply_scheme = damos_test_apply_scheme_stub;
-
- s = damon_new_scheme(&pattern, DAMOS_STAT, 0, "a, &wmarks,
- NUMA_NO_NODE);
- if (!s) {
- damon_destroy_ctx(c);
- kunit_skip(test, "scheme alloc fail");
- }
- damon_add_scheme(c, s);
-
- t = damon_new_target();
- if (!t) {
- damon_destroy_ctx(c);
- kunit_skip(test, "target alloc fail");
- }
- damon_add_target(c, t);
-
- f = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false);
- if (!f) {
- damon_destroy_ctx(c);
- kunit_skip(test, "filter alloc fail");
- }
- f->addr_range = (struct damon_addr_range){
- .start = 2 * min_sz, .end = 8 * min_sz};
- damos_add_filter(s, f);
- damos_set_filters_default_reject(s);
-
- /* wholly inside a reject range: not counted at all */
- r = damon_new_region(4 * min_sz, 6 * min_sz);
- if (!r) {
- damon_destroy_ctx(c);
- kunit_skip(test, "region alloc fail");
- }
- damon_add_region(r, t);
-
- damos_apply_scheme(c, t, r, s);
- KUNIT_EXPECT_EQ(test, s->stat.nr_tried, 0);
- KUNIT_EXPECT_EQ(test, s->stat.sz_tried, 0);
- KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1);
-
- /* wholly inside an allow range: counted whole, not split */
- f->allow = true;
- damos_set_filters_default_reject(s);
-
- damos_apply_scheme(c, t, r, s);
- KUNIT_EXPECT_EQ(test, s->stat.sz_tried, 2 * min_sz);
- KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1);
-
- /* two filters, each trimming: the size left after both is counted */
- damon_destroy_region(r, t);
- s->stat = (struct damos_stat){};
- f->allow = false;
- f->addr_range = (struct damon_addr_range){
- .start = 4 * min_sz, .end = 12 * min_sz};
- f2 = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false);
- if (!f2) {
- damon_destroy_ctx(c);
- kunit_skip(test, "filter alloc fail");
- }
- f2->addr_range = (struct damon_addr_range){
- .start = 2 * min_sz, .end = 3 * min_sz};
- damos_add_filter(s, f2);
- damos_set_filters_default_reject(s);
-
- r = damon_new_region(0, 8 * min_sz);
- if (!r) {
- damon_destroy_ctx(c);
- kunit_skip(test, "region alloc fail");
- }
- damon_add_region(r, t);
-
- damos_apply_scheme(c, t, r, s);
- KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 3);
- KUNIT_EXPECT_EQ(test, r->ar.end, 2 * min_sz);
- KUNIT_EXPECT_EQ(test, s->stat.sz_tried, 2 * min_sz);
-
- /* a core filter that never splits: counted whole */
- damos_destroy_filter(f2);
- damos_destroy_filter(f);
- f = damos_new_filter(DAMOS_FILTER_TYPE_TARGET, true, true);
- if (!f) {
- damon_destroy_ctx(c);
- kunit_skip(test, "filter alloc fail");
- }
- f->target_idx = 0;
- damos_add_filter(s, f);
- damos_set_filters_default_reject(s);
- s->stat = (struct damos_stat){};
-
- damos_apply_scheme(c, t, r, s);
- KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 3);
- KUNIT_EXPECT_EQ(test, r->ar.end, 2 * min_sz);
- KUNIT_EXPECT_EQ(test, s->stat.sz_tried, 2 * min_sz);
-
- damon_destroy_ctx(c);
-}
-
static void damos_test_apply_scheme_quota_sz(struct kunit *test)
{
struct damos_access_pattern pattern = {
@@ -2780,8 +2572,6 @@ static struct kunit_case damon_test_cases[] = {
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),
KUNIT_CASE(damos_test_apply_scheme_quota_sz),
KUNIT_CASE(damon_test_feed_loop_next_input),
KUNIT_CASE(damon_test_set_filters_default_reject),
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 14:52 [RFC PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
2026-12-01 14:52 ` [RFC PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox