From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SJ Park <sj@kernel.org>, damon@lists.linux.dev, linux-mm@kvack.org
Subject: [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target()
Date: Thu, 3 Dec 2026 07:08:18 -0800 [thread overview]
Message-ID: <20261203150821.730276-3-sj@kernel.org> (raw)
In-Reply-To: <20261203150821.730276-1-sj@kernel.org>
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
next prev parent reply other threads:[~2026-12-03 15:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` SJ Park [this message]
2026-12-03 15:26 ` [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target() 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:26 ` [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method sashiko-bot
2026-12-03 15:42 ` SJ Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203150821.730276-3-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox