Thread (8 messages) 8 messages, 5 authors, 12d ago

Re: [PATCH] mm/damon: add damos_node_eligible_mem_bp tracepoint

flat view

From: Ravi Jonnalagadda <hidden>
Date: 2026-10-10 00:23:34
Also in: damon, linux-mm, lkml

On Mon, Oct 5, 2026 at 3:04 AM Kunwu Chan [off-list ref] wrote:

Hi Ravi,

I agree with SJ that this would be more useful as a general quota-goal
tracepoint rather than being specific to NODE_ELIGIBLE_MEM_BP. The
target_value and current_value fields are not metric-specific.
Hi Kunwu,

Thank you for the review.  Agreed; I will make it a general quota goal
tracepoint, as I wrote in my reply to SJ.
On Sat,  3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda [off-list ref] wrote:
quoted
Add a tracepoint for DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP quota goal
evaluation.  The tracepoint fires once per quota-score computation when
the goal metric is DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP, exposing
context_idx, scheme_idx, nid, target_value, and current_value.
current_value is reported as the quota tuning sees it, after the goal's
complement setting is applied.

The DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP metric expresses node memory
occupancy as basis points of eligible bytes.  This information is not
exposed through any existing external interface (perf stat, /proc, or
sysfs), so the tracepoint is the only way for userspace to observe the
target and current eligible-memory basis point values at quota-scoring
time.

Link: https://lore.kernel.org/linux-mm/20260428030520.701-1-ravis.opensrc@gmail.com/ (local)
Signed-off-by: Ravi Jonnalagadda <redacted>
---
 include/trace/events/damon.h | 31 +++++++++++++++++++++++++++++++
 mm/damon/core.c              | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h
index 8851727ae162..2c7249cc7c88 100644
--- a/include/trace/events/damon.h
+++ b/include/trace/events/damon.h
@@ -74,6 +74,37 @@ TRACE_EVENT(damos_esz,
                      __entry->esz)
 );

+/* Per-tick DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP goal evaluation. */
The comment says "Per-tick", but the event is emitted for each matching
goal in damos_quota_score(). "Per quota-goal evaluation" would be more
precise.
Right, I will fix the comment.
quoted
+TRACE_EVENT(damos_node_eligible_mem_bp,
+
+     TP_PROTO(unsigned int context_idx, unsigned int scheme_idx,
+             int nid,
+             unsigned long target_value, unsigned long current_value),
+
+     TP_ARGS(context_idx, scheme_idx, nid, target_value, current_value),
+
+     TP_STRUCT__entry(
+             __field(unsigned int, context_idx)
+             __field(unsigned int, scheme_idx)
+             __field(int, nid)
+             __field(unsigned long, target_value)
+             __field(unsigned long, current_value)
Also, context_idx is currently always 0 here, since
damos_quota_score() only has struct damon_ctx * and no context index.
If this tracepoint is generalized, it may be worth considering how the
context/scheme are identified rather than introducing another tracepoint
field that is currently always 0.
I kept context_idx for consistency with damos_esz and
damos_before_apply, which carry the same field and also pass 0 today,
since a kdamond runs one context.  I will follow whatever SJ prefers
for identifying the context in the generalized event.

Thanks,
Ravi.
Thanks,
Kunwu
quoted
+     ),
+
+     TP_fast_assign(
+             __entry->context_idx = context_idx;
+             __entry->scheme_idx = scheme_idx;
+             __entry->nid = nid;
+             __entry->target_value = target_value;
+             __entry->current_value = current_value;
+     ),
+
+     TP_printk("ctx_idx=%u scheme_idx=%u nid=%d target_value=%lu current_value=%lu",
+                     __entry->context_idx, __entry->scheme_idx,
+                     __entry->nid,
+                     __entry->target_value, __entry->current_value)
+);
+
 TRACE_EVENT_CONDITION(damos_before_apply,

      TP_PROTO(unsigned int context_idx, unsigned int scheme_idx,
diff --git a/mm/damon/core.c b/mm/damon/core.c
index b63e60ef8990..6ddd15dc4f55 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3294,6 +3294,22 @@ static unsigned long damos_quota_score(struct damon_ctx *c, struct damos *s)
              highest_score = max(highest_score,
                              mult_frac(goal->current_value, 10000,
                                      goal->target_value));
+
+             if (goal->metric == DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP &&
+                 trace_damos_node_eligible_mem_bp_enabled()) {
+                     unsigned int cidx = 0, sidx = 0;
+                     struct damos *siter;
+
+                     damon_for_each_scheme(siter, c) {
+                             if (siter == s)
+                                     break;
+                             sidx++;
+                     }
+                     trace_damos_node_eligible_mem_bp(cidx, sidx,
+                                     goal->nid,
+                                     goal->target_value,
+                                     goal->current_value);
+             }
      }

      return highest_score;
base-commit: 763ad0211c7b587344f03bc4d1299810aeb736f4
--
2.54.0 (Apple Git-157)
Sent using hkml (https://github.com/sjp38/hackermail)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help