Aim-oriented monitoring intervals auto-tuning is an important and
recommended feature for DAMON users.  Add a trace event for the
observability of the tuned intervals and tuning itself.

Signed-off-by: SeongJae Park <[email protected]>
---
 include/trace/events/damon.h | 17 +++++++++++++++++
 mm/damon/core.c              |  1 +
 2 files changed, 18 insertions(+)

diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h
index da4bd9fd1162..32c611076023 100644
--- a/include/trace/events/damon.h
+++ b/include/trace/events/damon.h
@@ -48,6 +48,23 @@ TRACE_EVENT_CONDITION(damos_before_apply,
                        __entry->nr_accesses, __entry->age)
 );
 
+TRACE_EVENT(damon_monitor_intervals_tune,
+
+       TP_PROTO(unsigned long sample_us),
+
+       TP_ARGS(sample_us),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, sample_us)
+       ),
+
+       TP_fast_assign(
+               __entry->sample_us = sample_us;
+       ),
+
+       TP_printk("sample_us=%lu", __entry->sample_us)
+);
+
 TRACE_EVENT(damon_aggregated,
 
        TP_PROTO(unsigned int target_id, struct damon_region *r,
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 979b29e16ef4..57a1ace4d10d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1490,6 +1490,7 @@ static void kdamond_tune_intervals(struct damon_ctx *c)
                        new_attrs.sample_interval);
        new_attrs.aggr_interval = new_attrs.sample_interval *
                c->attrs.aggr_samples;
+       trace_damon_monitor_intervals_tune(new_attrs.sample_interval);
        damon_set_attrs(c, &new_attrs);
 }
 
-- 
2.39.5

Reply via email to