Skip to contentSkip to conversation

mm/damon: add damos_node_eligible_mem_bp tracepoint

PATCH In review Ravi Jonnalagadda 5 participants 8 messages Oct 3 – Oct 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/damon: add damos_node_eligible_mem_bp tracepoint

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.

---
 include/trace/events/damon.h | 31 +++++++++++++++++++++++++++++++
 mm/damon/core.c              | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
include/trace/events/damon.h +31 -0
index 8851727ae162..2c7249cc7c88 100644
@@ -74,6 +74,37 @@ TRACE_EVENT(damos_esz,
 			__entry->esz)
 );
 
+/* Per-tick DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP goal evaluation. */
+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)
+	),
+
+	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,
mm/damon/core.c +16 -0
index b63e60ef8990..6ddd15dc4f55 100644
@@ -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

Signature · 1 line
2.54.0 (Apple Git-157)
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 14 lines

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.

Quoted 2 lines

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Ravi Jonnalagadda

Hi Ravi,

Quoted 7 lines · On Sat, 3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda <[email protected]>…

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.

Quoted 6 lines

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.

Thank you for this patch!

We have damos_esz tracepoint. Have you considered using it? It doesn't expose the current value, though. I thought it wouldn't be real problem in most cases, but I can show it could be problematic for node_eligible_mem_bp case, as the metric value is not straightforward to see without using DAMON.

If you really need to know the current_value, I'm open to add a new tracepoint. But I think it has no reason to make it only eligible_mem_bp specific. How about adding more general purpose tracepoint, and/or update the current_value file [1] under the goal sysfs directory to show the current current_value for all goal types?

[1] https://origin.kernel.org/doc/html/latest/admin-guide/mm/damon/usage.html#sysfs-schemes-quota-goals

Thanks,
SJ

[...]

#3 lore raw
Quoted 19 lines · SJ Park

Hi Ravi,

Quoted 7 lines · On Sat, 3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda <[email protected]>…

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.

Quoted 6 lines

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.

Quoted 6 lines

Thank you for this patch!

We have damos_esz tracepoint. Have you considered using it? It doesn't expose the current value, though. I thought it wouldn't be real problem in most cases, but I can show it could be problematic for node_eligible_mem_bp case, as the metric value is not straightforward to see without using DAMON.

Hi SJ,

Yes, with the temporal goal tuner, damos_esz only
tells whether the goal is met, not how close current_value is to target_value, and damo needs that to know when a step has settled.

Quoted 7 lines

If you really need to know the current_value, I'm open to add a new tracepoint. But I think it has no reason to make it only eligible_mem_bp specific. How about adding more general purpose tracepoint, and/or update the current_value file [1] under the goal sysfs directory to show the current current_value for all goal types?

Agreed, nothing in it needs to be specific to node_eligible_mem_bp. I will rework it as a general quota goal tracepoint, emitted for each goal evaluation with the goal's metric, target_value and current_value, the node id for the node metrics, and the memcg id for the memcg metrics.

I would leave the current_value file as it is for now. It would need a stats update command or refresh_ms to stay current, and damo wants every evaluation as it happens, which the tracepoint gives it.

Thanks,
Ravi.

Quoted 7 lines

[1] https://origin.kernel.org/doc/html/latest/admin-guide/mm/damon/usage.html#sysfs-schemes-quota-goals

Thanks,
SJ

[...]

maintainer
#4 lore raw
In reply to Ravi Jonnalagadda
Quoted 32 lines · On Sat, 3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda <[email protected]>…

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.

---
 include/trace/events/damon.h | 31 +++++++++++++++++++++++++++++++
 mm/damon/core.c              | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
include/trace/events/damon.h +3 -0
index 8851727ae162..2c7249cc7c88 100644
@@ -74,6 +74,37 @@ TRACE_EVENT(damos_esz,
 			__entry->esz)
 );
 
+/* Per-tick DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP goal evaluation. */
+TRACE_EVENT(damos_node_eligible_mem_bp,
+

include/trace/events/damon.h TRACE_EVENT(damos_esz, · line 89

Quoted 10 lines
include/trace/events/damon.h +10 -0
+	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)

Can you move the nid after the two unsigned long values below. This creates a structure, and on 64bit machines, this adds a 4 byte padding in the middle of the ring buffer.

Quoted 26 lines
include/trace/events/damon.h +18 -0
+		__field(unsigned long, target_value)
+		__field(unsigned long, current_value)
+	),
+
+	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,
mm/damon/core.c +0 -0
index b63e60ef8990..6ddd15dc4f55 100644

mm/damon/core.c static unsigned long damos_quota_score(struct damon_ctx *c, struct damos *s) · line 3299

Quoted 6 lines
mm/damon/core.c +3 -0
@@ -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()) {

If you move the trace_damos_node_eligible_mem_bp_enabled() before the goal->metric check, you will save yourself a branch when tracing is off. As the trace_*_enabled() is a static branch (nop or jmp) it has no cmp branch, but the above will keep the goal->metric still exposed. By swapping the two compares, the goal->metric check will be hidder behind the 'nop' when tracing is disabled.

-- Steve

Quoted 18 lines
mm/damon/core.c +13 -0
+			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

#5 lore raw
Quoted 42 lines · Steven Rostedt
Quoted 38 lines · On Sat, 3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda <[email protected]>…

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.

---
 include/trace/events/damon.h | 31 +++++++++++++++++++++++++++++++
 mm/damon/core.c              | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
include/trace/events/damon.h +9 -0
index 8851727ae162..2c7249cc7c88 100644
@@ -74,6 +74,37 @@ TRACE_EVENT(damos_esz,
                      __entry->esz)
 );
 
+/* Per-tick DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP goal evaluation. */
+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),
+
Quoted 8 lines

include/trace/events/damon.h TRACE_EVENT(damos_esz, · line 89

Quoted 4 lines
include/trace/events/damon.h +4 -0
+     TP_STRUCT__entry(
+             __field(unsigned int, context_idx)
+             __field(unsigned int, scheme_idx)
+             __field(int, nid)

Can you move the nid after the two unsigned long values below. This creates a structure, and on 64bit machines, this adds a 4 byte padding in the middle of the ring buffer.

Hi Steve,

Thank you. Will do; in the next version the 8-byte fields come first and nid follows them.

Quoted 41 lines
Quoted 27 lines
include/trace/events/damon.h +18 -0
+             __field(unsigned long, target_value)
+             __field(unsigned long, current_value)
+     ),
+
+     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,
mm/damon/core.c +0 -0
index b63e60ef8990..6ddd15dc4f55 100644

mm/damon/core.c static unsigned long damos_quota_score(struct damon_ctx *c, struct damos *s) · line 3299

Quoted 6 lines
mm/damon/core.c +3 -0
@@ -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()) {

If you move the trace_damos_node_eligible_mem_bp_enabled() before the goal->metric check, you will save yourself a branch when tracing is off. As the trace_*_enabled() is a static branch (nop or jmp) it has no cmp branch, but the above will keep the goal->metric still exposed. By swapping the two compares, the goal->metric check will be hidder behind the 'nop' when tracing is disabled.

Quoted 1 line

-- Steve

Makes sense; I will put the trace_*_enabled() check first. SJ asked for the event to cover every quota goal rather than this metric only, so the next version may not need the metric check at all, but the enabled check will lead either way.

Thanks,
Ravi

Quoted 21 lines
Quoted 20 lines
mm/damon/core.c +13 -0
+                     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

#6 lore raw
In reply to Ravi Jonnalagadda

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.

Quoted 26 lines · On Sat, 3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda <[email protected]>…

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.

---
 include/trace/events/damon.h | 31 +++++++++++++++++++++++++++++++
 mm/damon/core.c              | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
include/trace/events/damon.h +0 -0
index 8851727ae162..2c7249cc7c88 100644

include/trace/events/damon.h TRACE_EVENT(damos_esz, · line 77

Quoted 4 lines
include/trace/events/damon.h +1 -0
@@ -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.

Quoted 4 lines
include/trace/events/damon.h +4 -0
+TRACE_EVENT(damos_node_eligible_mem_bp,
+
+	TP_PROTO(unsigned int context_idx, unsigned int scheme_idx,
+		int nid,

include/trace/events/damon.h TRACE_EVENT(damos_esz, · line 91

Quoted 10 lines
include/trace/events/damon.h +10 -0
+		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.

Thanks,
Kunwu

Quoted 47 lines
include/trace/events/damon.h +16 -0
+	),
+
+	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,
mm/damon/core.c +16 -0
index b63e60ef8990..6ddd15dc4f55 100644
@@ -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;
Quoted 5 lines

base-commit: 763ad0211c7b587344f03bc4d1299810aeb736f4

Signature · 1 line
2.54.0 (Apple Git-157)

Sent using hkml (https://github.com/sjp38/hackermail)

#7 lore raw
Quoted 7 lines · Kunwu Chan

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.

Quoted 32 lines · On Sat, 3 Oct 2026 13:27:27 -0700 Ravi Jonnalagadda <[email protected]>…
Quoted 30 lines

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.

---
 include/trace/events/damon.h | 31 +++++++++++++++++++++++++++++++
 mm/damon/core.c              | 16 ++++++++++++++++
 2 files changed, 47 insertions(+)
include/trace/events/damon.h +0 -0
index 8851727ae162..2c7249cc7c88 100644
@@ -74,6 +74,37 @@ TRACE_EVENT(damos_esz,
                      __entry->esz)
 );
 
Quoted 5 lines

include/trace/events/damon.h TRACE_EVENT(damos_esz, · line 77

Quoted 1 line
include/trace/events/damon.h +1 -0
+/* 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 13 lines
Quoted 13 lines
include/trace/events/damon.h +12 -0
+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)
Quoted 8 lines

include/trace/events/damon.h TRACE_EVENT(damos_esz, · line 91

Quoted 2 lines
include/trace/events/damon.h +2 -0
+             __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.

Quoted 58 lines

Thanks,
Kunwu

Quoted 47 lines
include/trace/events/damon.h +16 -0
+     ),
+
+     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,
mm/damon/core.c +16 -0
index b63e60ef8990..6ddd15dc4f55 100644
@@ -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;
Quoted 5 lines

base-commit: 763ad0211c7b587344f03bc4d1299810aeb736f4 --
2.54.0 (Apple Git-157)

Sent using hkml (https://github.com/sjp38/hackermail)