* [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method
@ 2026-12-03 15:08 SJ Park
2026-12-03 15:08 ` [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:08 UTC (permalink / raw)
To: Andrew Morton
Cc: SJ Park, Brendan Higgins, David Gow, damon, kunit-dev,
linux-kselftest, linux-mm
DAMOS access pattern and core filters are treated as a primary and a
secondary target region selection method, respectively. DAMOS target
regions are initially selected with the access pattern. Later core
filters are applied additionally when needed, in the middle of lower
level operations. DAMOS quota goal type eligible_mem_bp is ignoring the
core filters.
Core filters are effectively applied on all places that
damos_access_pattern is applied, except the eligible_mem_bp DAMOS quota
goal type handling.
Promote DAMOS core filters to a primary target selection method. Use it
in the central high level place that the damos_access_pattern is
handled. Split out damos_access_pattern to a function and call it
directly from the eligible_mem_bp handling, to keep the old behavior.
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 kernel-doc comment, via patch 3.
Changes from v1
- v1: https://lore.kernel.org/20261202151518.618069-1-sj@kernel.org
- Restore eligible_mem_bp behavior.
- Wordsmith commit message.
Changes from RFC v2
- RFC v2: https://lore.kernel.org/20261201145302.91868-1-sj@kernel.org
- Rebase to the latest mm-new.
- Drop RFC.
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()
mm/damon/api: clarify node_eligible_mem_bp is access pattern-eligible
include/linux/damon.h | 5 +-
mm/damon/core.c | 31 ++++--
mm/damon/tests/core-kunit.h | 210 ------------------------------------
3 files changed, 23 insertions(+), 223 deletions(-)
base-commit: 1a7610248a3802e38124ce66b07eef12277be9a0
--
2.47.3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
2026-12-03 15:08 [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
@ 2026-12-03 15:08 ` SJ Park
2026-12-03 15:19 ` sashiko-bot
2026-12-03 15:08 ` [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target() SJ Park
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:08 UTC (permalink / raw)
To: Andrew Morton
Cc: SJ Park, 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] 9+ messages in thread
* [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target()
2026-12-03 15:08 [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
2026-12-03 15:08 ` [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
@ 2026-12-03 15:08 ` SJ Park
2026-12-03 15:26 ` sashiko-bot
2026-12-03 15:08 ` [PATCH v2 3/3] mm/damon/api: clarify node_eligible_mem_bp is access pattern-eligible SJ Park
2026-12-03 15:42 ` [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
3 siblings, 1 reply; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: SJ Park, damon, linux-mm
DAMOS uses damos_access_pattern as the primary target region selection
method. Meanwhile, DAMOS core filters are used as a secondary method.
The filters are applied when needed, in addition to damos access pattern
check.
There is no real reason to keep filters as secondary class. DAMOS core
filters are effectively applied on every place that damos_acces_pattern
is applied. The node_eligible_mem_bp DAMOS quota goal type handling is
the only one exception. Having DAMOS core filters handling in multiple
places only makes it easy to add mistakes. Also, probe_hits_wsum DAMOS
core filter type is the only method to specify DAMOS target regions with
probe_hits. For this reason, core filters become the primary target
region selection method in the attributes only monitoring mode.
Treat DAMOS core filter as the primary method. Handle core filters and
damos_access_pattern together in the central region selection function,
__damos_valid_target(). Update __damos_valid_target() to receive
damon_ctx, to allow it access to core filters.
The node_eligible_mem_bp DAMOS quota goal type intentionally ignores
core filters. Keep the behavior by splitting damos_access_pattern check
logic out of __damos_valid_target(), and call it from the quota goal
handling.
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/core.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 2766ebec0150..b0e9325e032b 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2535,8 +2535,12 @@ static noinline_for_stack void kdamond_tune_intervals(struct damon_ctx *c)
damon_set_attrs(c, &new_attrs);
}
-static bool __damos_valid_target(struct damon_region *r, struct damos *s,
- struct damon_ctx *c)
+static bool damos_core_filter_out(struct damon_ctx *ctx,
+ struct damon_target *t, struct damon_region *r,
+ struct damos *s);
+
+static bool damos_access_pattern_eligible(struct damon_region *r,
+ struct damos *s, struct damon_ctx *c)
{
unsigned long sz;
unsigned int nr_accesses = damon_nr_accesses_mvsum(r, c);
@@ -2550,6 +2554,15 @@ static bool __damos_valid_target(struct damon_region *r, struct damos *s,
r->age <= s->pattern.max_age_region;
}
+static bool __damos_valid_target(struct damon_region *r, struct damos *s,
+ struct damon_ctx *c, struct damon_target *t)
+{
+ if (damos_core_filter_out(c, t, r, s))
+ return false;
+
+ return damos_access_pattern_eligible(r, s, c);
+}
+
/*
* damos_quota_is_set() - Return if the given quota is actually set.
* @quota: The quota to check.
@@ -2563,9 +2576,9 @@ static bool damos_quota_is_set(struct damos_quota *quota)
}
static bool damos_valid_target(struct damon_ctx *c, struct damon_region *r,
- struct damos *s)
+ struct damos *s, struct damon_target *t)
{
- bool ret = __damos_valid_target(r, s, c);
+ bool ret = __damos_valid_target(r, s, c, t);
if (!ret || !damos_quota_is_set(&s->quota) || !c->ops.get_scheme_score)
return ret;
@@ -2896,8 +2909,6 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
}
if (c->ops.apply_scheme) {
- if (damos_core_filter_out(c, t, r, s))
- return;
sz = damon_sz_region(r);
if (damos_quota_is_set(quota) &&
quota->charged_sz + sz > quota->esz) {
@@ -2957,7 +2968,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
s->max_nr_snapshots <= s->stat.nr_snapshots)
continue;
- if (damos_valid_target(c, r, s))
+ if (damos_valid_target(c, r, s, t))
damos_apply_scheme(c, t, r, s);
if (damon_is_last_region(r, t))
@@ -3218,7 +3229,7 @@ static phys_addr_t damos_calc_eligible_bytes(struct damon_ctx *c,
damon_for_each_region(r, t) {
phys_addr_t addr, end_addr;
- if (!__damos_valid_target(r, s, c))
+ if (!damos_access_pattern_eligible(r, s, c))
continue;
/* Convert from core address units to physical bytes */
@@ -3565,9 +3576,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
(DAMOS_MAX_SCORE + 1));
damon_for_each_target(t, c) {
damon_for_each_region(r, t) {
- if (!__damos_valid_target(r, s, c))
- continue;
- if (damos_core_filter_out(c, t, r, s))
+ if (!__damos_valid_target(r, s, c, t))
continue;
score = c->ops.get_scheme_score(c, r, s);
c->regions_score_histogram[score] +=
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] mm/damon/api: clarify node_eligible_mem_bp is access pattern-eligible
2026-12-03 15:08 [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
2026-12-03 15:08 ` [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
2026-12-03 15:08 ` [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target() SJ Park
@ 2026-12-03 15:08 ` SJ Park
2026-12-03 15:42 ` [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
3 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: SJ Park, damon, linux-mm
The node_eligible_mem_bp is for memory that is eligible by the
damos_access_pattern. It doesn’t count DAMOS core filters. Its name
and the kernel-doc comment are not quite clear about that. Update the
kernel-doc to make it clearer.
Signed-off-by: SJ Park <sj@kernel.org>
---
include/linux/damon.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 45c82f536da5..f60e696d69c5 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -149,8 +149,9 @@ enum damos_action {
* @DAMOS_QUOTA_NODE_MEMCG_FREE_BP: MemFree ratio of a node for a cgroup.
* @DAMOS_QUOTA_ACTIVE_MEM_BP: Active to total LRU memory ratio.
* @DAMOS_QUOTA_INACTIVE_MEM_BP: Inactive to total LRU memory ratio.
- * @DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP: Scheme-eligible memory ratio of a
- * node in basis points (0-10000).
+ * @DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP: Scheme access pattern-eligible memory
+ * ratio of a node in basis points
+ * (0-10000).
* @DAMOS_QUOTA_HUGEPAGE_MEM_BP: Huge page to total used memory ratio.
*/
enum damos_quota_goal_metric {
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
2026-12-03 15:08 ` [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
@ 2026-12-03 15:19 ` sashiko-bot
2026-12-03 15:36 ` SJ Park
0 siblings, 1 reply; 9+ messages in thread
From: sashiko-bot @ 2026-12-03 15:19 UTC (permalink / raw)
To: SJ Park, Andrew Morton
Cc: Brendan Higgins, David Gow, damon, kunit-dev, linux-mm
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm/damon: inaccurate changelog and lost damos_core_filter_out()
test coverage
--
commit 883df66be28904c403ef8497729b0e102d93b4f3
Author: SJ Park <sj@kernel.org>
> mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
>
> 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>
[Severity: Low]
Does removing these two tests drop all KUnit coverage for
damos_core_filter_out() rather than removing duplicates?
damos_test_filter_out() only calls damos_filter_match() on a single
DAMOS_FILTER_TYPE_ADDR filter and never invokes damos_core_filter_out().
Dropping these tests leaves core filter evaluation (allow/reject,
default reject, multi-filter trimming) and size accounting untested.
The changelog also omits that the follow-up commit "mm/damon/core: apply
damos core filter in __damos_valid_target()" moves
damos_core_filter_out() out of damos_apply_scheme(), which is why the
tests cannot stay as written.
Updating the changelog and migrating the tests to cover
damos_core_filter_out() or __damos_valid_target() would keep coverage.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203150821.730276-1-sj@kernel.org?part=1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target()
2026-12-03 15:08 ` [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target() SJ Park
@ 2026-12-03 15:26 ` sashiko-bot
2026-12-03 15:40 ` SJ Park
0 siblings, 1 reply; 9+ messages in thread
From: sashiko-bot @ 2026-12-03 15:26 UTC (permalink / raw)
To: SJ Park, Andrew Morton; +Cc: damon, linux-mm
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] mm/damon: core filter runs before access pattern in
__damos_valid_target()
- [Low] mm/damon: commit message misstates parameter added to
__damos_valid_target()
- [Low] mm/damon: redundant damon_sz_region() assignment in
damos_apply_scheme()
--
commit 65ff401f1d42c531dc70b0b39a702a59a8905c6f
Author: SJ Park <sj@kernel.org>
mm/damon/core: apply damos core filter in __damos_valid_target()
This commit moves DAMOS core filter evaluation into __damos_valid_target()
and splits out damos_access_pattern_eligible() for callers that only check
the access pattern.
> Treat DAMOS core filter as the primary method. Handle core filters and
> damos_access_pattern together in the central region selection function,
> __damos_valid_target(). Update __damos_valid_target() to receive
> damon_ctx, to allow it access to core filters.
[Severity: Low]
__damos_valid_target() already received struct damon_ctx *c; this commit
adds struct damon_target *t so it can be passed to damos_core_filter_out().
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 2766ebec01501..b0e9325e032b6 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -2550,6 +2554,15 @@ static bool __damos_valid_target(struct damon_region *r, struct damos *s,
> r->age <= s->pattern.max_age_region;
> }
>
> +static bool __damos_valid_target(struct damon_region *r, struct damos *s,
> + struct damon_ctx *c, struct damon_target *t)
> +{
> + if (damos_core_filter_out(c, t, r, s))
> + return false;
> +
> + return damos_access_pattern_eligible(r, s, c);
> +}
[Severity: Medium]
Can running damos_core_filter_out() before damos_access_pattern_eligible()
cause DAMOS_FILTER_TYPE_ADDR splits to break region size checks?
For a partially overlapping DAMOS_FILTER_TYPE_ADDR filter,
damos_filter_match() calls damon_split_region_at() and shrinks r in place.
damos_access_pattern_eligible() then checks min_sz_region and max_sz_region
against the post-split slice instead of the original region.
A region larger than max_sz_region can then be split into a smaller slice
and erroneously receive the scheme action, while an eligible region with a
narrower filter overlap is falsely rejected under min_sz_region. Regions
failing nr_accesses or age are also split before later schemes evaluate them.
Checking damos_access_pattern_eligible() before damos_core_filter_out()
would preserve the previous semantics.
[ ... ]
> @@ -2896,8 +2909,6 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
> }
>
> if (c->ops.apply_scheme) {
> - if (damos_core_filter_out(c, t, r, s))
> - return;
> sz = damon_sz_region(r);
> if (damos_quota_is_set(quota) &&
> quota->charged_sz + sz > quota->esz) {
[Severity: Low]
Is this sz = damon_sz_region(r) assignment now redundant? sz is already
initialized to damon_sz_region(r) at the start of damos_apply_scheme(), and
nothing modifies r in between now that damos_core_filter_out() has been
removed here.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203150821.730276-1-sj@kernel.org?part=2
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
2026-12-03 15:19 ` sashiko-bot
@ 2026-12-03 15:36 ` SJ Park
0 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:36 UTC (permalink / raw)
To: sashiko-bot
Cc: SJ Park, Andrew Morton, Brendan Higgins, David Gow, damon,
kunit-dev, linux-mm
On Thu, 03 Dec 2026 15:19:51 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] mm/damon: inaccurate changelog and lost damos_core_filter_out()
> test coverage
> --
>
> commit 883df66be28904c403ef8497729b0e102d93b4f3
> Author: SJ Park <sj@kernel.org>
>
> > mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests
> >
> > 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>
>
> [Severity: Low]
> Does removing these two tests drop all KUnit coverage for
> damos_core_filter_out() rather than removing duplicates?
>
> damos_test_filter_out() only calls damos_filter_match() on a single
> DAMOS_FILTER_TYPE_ADDR filter and never invokes damos_core_filter_out().
> Dropping these tests leaves core filter evaluation (allow/reject,
> default reject, multi-filter trimming) and size accounting untested.
>
> The changelog also omits that the follow-up commit "mm/damon/core: apply
> damos core filter in __damos_valid_target()" moves
> damos_core_filter_out() out of damos_apply_scheme(), which is why the
> tests cannot stay as written.
>
> Updating the changelog and migrating the tests to cover
> damos_core_filter_out() or __damos_valid_target() would keep coverage.
We could add more test cases to damos_test_filter_out() as a followup. The
coverletter is explaining why the tests need to be dropped.
So, no blocker in my opinion.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261203150821.730276-1-sj@kernel.org?part=1
>
Thanks,
SJ
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target()
2026-12-03 15:26 ` sashiko-bot
@ 2026-12-03 15:40 ` SJ Park
0 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:40 UTC (permalink / raw)
To: sashiko-bot; +Cc: SJ Park, Andrew Morton, damon, linux-mm
On Thu, 03 Dec 2026 15:26:47 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [Medium] mm/damon: core filter runs before access pattern in
> __damos_valid_target()
> - [Low] mm/damon: commit message misstates parameter added to
> __damos_valid_target()
> - [Low] mm/damon: redundant damon_sz_region() assignment in
> damos_apply_scheme()
> --
>
> commit 65ff401f1d42c531dc70b0b39a702a59a8905c6f
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/core: apply damos core filter in __damos_valid_target()
>
> This commit moves DAMOS core filter evaluation into __damos_valid_target()
> and splits out damos_access_pattern_eligible() for callers that only check
> the access pattern.
>
> > Treat DAMOS core filter as the primary method. Handle core filters and
> > damos_access_pattern together in the central region selection function,
> > __damos_valid_target(). Update __damos_valid_target() to receive
> > damon_ctx, to allow it access to core filters.
>
> [Severity: Low]
> __damos_valid_target() already received struct damon_ctx *c; this commit
> adds struct damon_target *t so it can be passed to damos_core_filter_out().
Good check. I will fix the commit message.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 2766ebec01501..b0e9325e032b6 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
>
> [ ... ]
>
> > @@ -2550,6 +2554,15 @@ static bool __damos_valid_target(struct damon_region *r, struct damos *s,
> > r->age <= s->pattern.max_age_region;
> > }
> >
> > +static bool __damos_valid_target(struct damon_region *r, struct damos *s,
> > + struct damon_ctx *c, struct damon_target *t)
> > +{
> > + if (damos_core_filter_out(c, t, r, s))
> > + return false;
> > +
> > + return damos_access_pattern_eligible(r, s, c);
> > +}
>
> [Severity: Medium]
> Can running damos_core_filter_out() before damos_access_pattern_eligible()
> cause DAMOS_FILTER_TYPE_ADDR splits to break region size checks?
>
> For a partially overlapping DAMOS_FILTER_TYPE_ADDR filter,
> damos_filter_match() calls damon_split_region_at() and shrinks r in place.
> damos_access_pattern_eligible() then checks min_sz_region and max_sz_region
> against the post-split slice instead of the original region.
>
> A region larger than max_sz_region can then be split into a smaller slice
> and erroneously receive the scheme action, while an eligible region with a
> narrower filter overlap is falsely rejected under min_sz_region. Regions
> failing nr_accesses or age are also split before later schemes evaluate them.
>
> Checking damos_access_pattern_eligible() before damos_core_filter_out()
> would preserve the previous semantics.
Good point. I will update this code to check damos_access_pattern before core
filters.
>
> [ ... ]
>
> > @@ -2896,8 +2909,6 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
> > }
> >
> > if (c->ops.apply_scheme) {
> > - if (damos_core_filter_out(c, t, r, s))
> > - return;
> > sz = damon_sz_region(r);
> > if (damos_quota_is_set(quota) &&
> > quota->charged_sz + sz > quota->esz) {
>
> [Severity: Low]
> Is this sz = damon_sz_region(r) assignment now redundant? sz is already
> initialized to damon_sz_region(r) at the start of damos_apply_scheme(), and
> nothing modifies r in between now that damos_core_filter_out() has been
> removed here.
Correct. I will remove the redundant assignment.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261203150821.730276-1-sj@kernel.org?part=2
>
Thanks,
SJ
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method
2026-12-03 15:08 [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
` (2 preceding siblings ...)
2026-12-03 15:08 ` [PATCH v2 3/3] mm/damon/api: clarify node_eligible_mem_bp is access pattern-eligible SJ Park
@ 2026-12-03 15:42 ` SJ Park
3 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-12-03 15:42 UTC (permalink / raw)
To: SJ Park
Cc: Andrew Morton, Brendan Higgins, David Gow, damon, kunit-dev,
linux-kselftest, linux-mm
On Thu, 3 Dec 2026 07:08:16 -0800 SJ Park <sj@kernel.org> wrote:
> DAMOS access pattern and core filters are treated as a primary and a
> secondary target region selection method, respectively. DAMOS target
> regions are initially selected with the access pattern. Later core
> filters are applied additionally when needed, in the middle of lower
> level operations. DAMOS quota goal type eligible_mem_bp is ignoring the
> core filters.
>
> Core filters are effectively applied on all places that
> damos_access_pattern is applied, except the eligible_mem_bp DAMOS quota
> goal type handling.
>
> Promote DAMOS core filters to a primary target selection method. Use it
> in the central high level place that the damos_access_pattern is
> handled. Split out damos_access_pattern to a function and call it
> directly from the eligible_mem_bp handling, to keep the old behavior.
>
> 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 kernel-doc comment, via patch 3.
Sashiko found [1] a few things that are better to be fixed. I will post a new
version with the fixes.
[1] https://lore.kernel.org/20261203154045.733625-1-sj@kernel.org
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-03 15:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 15:08 [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
2026-12-03 15:08 ` [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
2026-12-03 15:19 ` sashiko-bot
2026-12-03 15:36 ` SJ Park
2026-12-03 15:08 ` [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target() SJ Park
2026-12-03 15:26 ` sashiko-bot
2026-12-03 15:40 ` SJ Park
2026-12-03 15:08 ` [PATCH v2 3/3] mm/damon/api: clarify node_eligible_mem_bp is access pattern-eligible SJ Park
2026-12-03 15:42 ` [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox