From: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
To: damon@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Cc: sj@kernel.org, akpm@linux-foundation.org, corbet@lwn.net,
bijan311@gmail.com, ajayjoshi@micron.com,
Ravi Jonnalagadda <ravis.opensrc@gmail.com>
Subject: [RFC PATCH 3/5] mm/damon/core: add new ops-specific goal metric
Date: Thu, 22 Jan 2026 20:57:26 -0800 [thread overview]
Message-ID: <20260123045733.6954-4-ravis.opensrc@gmail.com> (raw)
In-Reply-To: <20260123045733.6954-1-ravis.opensrc@gmail.com>
Convert static functions in core.c to pass damon_ctx* and damos* down to
`damos_set_quota_goal_current_value()`. This keeps all goal metrics (PSI,
node_mem*, node_memcg*, and the new node_sys_bp) computed in one place,
while core remains generic and ops-specific computation is delegated via
ctx->ops.get_goal_metric().
Only static functions in this file are touched; no external ABI changes.
Signed-off-by: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
---
mm/damon/core.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 84f80a20f233..d898bfcbef72 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2119,8 +2119,20 @@ static unsigned long damos_get_node_memcg_used_bp(
}
#endif
+static unsigned long
+damos_get_goal_metric_from_ops(struct damon_ctx *ctx, struct damos *scheme,
+ const struct damos_quota_goal *goal)
+{
+ if (!ctx || !goal)
+ return 0;
+ if (!ctx->ops.get_goal_metric)
+ return 0;
+ return ctx->ops.get_goal_metric(ctx, scheme, goal);
+}
-static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal)
+static void damos_set_quota_goal_current_value(struct damon_ctx *ctx,
+ struct damos *scheme,
+ struct damos_quota_goal *goal)
{
u64 now_psi_total;
@@ -2141,19 +2153,25 @@ static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal)
case DAMOS_QUOTA_NODE_MEMCG_FREE_BP:
goal->current_value = damos_get_node_memcg_used_bp(goal);
break;
+ case DAMOS_QUOTA_NODE_SYS_BP:
+ goal->current_value = damos_get_goal_metric_from_ops(ctx,
+ scheme, goal);
+ break;
default:
break;
}
}
/* Return the highest score since it makes schemes least aggressive */
-static unsigned long damos_quota_score(struct damos_quota *quota)
+static unsigned long damos_quota_score(struct damon_ctx *ctx,
+ struct damos *scheme,
+ struct damos_quota *quota)
{
struct damos_quota_goal *goal;
unsigned long highest_score = 0;
damos_for_each_quota_goal(goal, quota) {
- damos_set_quota_goal_current_value(goal);
+ damos_set_quota_goal_current_value(ctx, scheme, goal);
highest_score = max(highest_score,
goal->current_value * 10000 /
goal->target_value);
@@ -2165,7 +2183,9 @@ static unsigned long damos_quota_score(struct damos_quota *quota)
/*
* Called only if quota->ms, or quota->sz are set, or quota->goals is not empty
*/
-static void damos_set_effective_quota(struct damos_quota *quota)
+static void damos_set_effective_quota(struct damon_ctx *ctx,
+ struct damos *scheme,
+ struct damos_quota *quota)
{
unsigned long throughput;
unsigned long esz = ULONG_MAX;
@@ -2176,7 +2196,7 @@ static void damos_set_effective_quota(struct damos_quota *quota)
}
if (!list_empty("a->goals)) {
- unsigned long score = damos_quota_score(quota);
+ unsigned long score = damos_quota_score(ctx, scheme, quota);
quota->esz_bp = damon_feed_loop_next_input(
max(quota->esz_bp, 10000UL),
@@ -2227,7 +2247,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
/* First charge window */
if (!quota->total_charged_sz && !quota->charged_from) {
quota->charged_from = jiffies;
- damos_set_effective_quota(quota);
+ damos_set_effective_quota(c, s, quota);
}
/* New charge window starts */
@@ -2240,7 +2260,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
quota->charged_sz = 0;
if (trace_damos_esz_enabled())
cached_esz = quota->esz;
- damos_set_effective_quota(quota);
+ damos_set_effective_quota(c, s, quota);
if (trace_damos_esz_enabled() && quota->esz != cached_esz)
damos_trace_esz(c, s, quota);
}
--
2.43.0
next prev parent reply other threads:[~2026-01-23 4:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 4:57 [RFC PATCH 0/5] mm/damon: Add node_sys_bp quota goal metric for PA-based migration control Ravi Jonnalagadda
2026-01-23 4:57 ` [RFC PATCH 1/5] mm/damon/core: add DAMOS_QUOTA_NODE_SYS_BP metric Ravi Jonnalagadda
2026-01-23 4:57 ` [RFC PATCH 2/5] mm/damon: add get_goal_metric() op and PA provider Ravi Jonnalagadda
2026-01-23 4:57 ` Ravi Jonnalagadda [this message]
2026-01-23 4:57 ` [RFC PATCH 4/5] mm/damon/paddr: capacity clamp and directional early-exit for node_sys_bp Ravi Jonnalagadda
2026-01-23 4:57 ` [RFC PATCH 5/5] mm/damon/sysfs-schemes: accept "node_sys_bp" in goal's target_metric Ravi Jonnalagadda
2026-01-24 1:50 ` [RFC PATCH 0/5] mm/damon: Add node_sys_bp quota goal metric for PA-based migration control SeongJae Park
2026-01-27 18:52 ` Ravi Jonnalagadda
2026-01-28 1:25 ` SeongJae Park
2026-02-12 6:27 ` SeongJae Park
2026-02-04 2:25 ` [RFC PATCH 0/5] mm/damon: Add node_sys_bp quota goal metric for Yunjeong Mun
2026-02-04 6:06 ` SeongJae Park
2026-02-12 6:30 ` SeongJae 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=20260123045733.6954-4-ravis.opensrc@gmail.com \
--to=ravis.opensrc@gmail.com \
--cc=ajayjoshi@micron.com \
--cc=akpm@linux-foundation.org \
--cc=bijan311@gmail.com \
--cc=corbet@lwn.net \
--cc=damon@lists.linux.dev \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.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