]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/damon: add trace event for effective size quota
authorSeongJae Park <sj@kernel.org>
Fri, 4 Jul 2025 22:14:08 +0000 (15:14 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 13 Jul 2025 23:38:33 +0000 (16:38 -0700)
Aim-oriented DAMOS quota auto-tuning is an important and recommended
feature for DAMOS users.  Add a trace event for the observability of the
tuned quota and tuning itself.

[sj@kernel.org: initialize sidx in damos_trace_esz()]
Link: https://lkml.kernel.org/r/20250705172003.52324-1-sj@kernel.org
[sj@kernel.org: make damos_esz unconditional trace event]
Link: https://lkml.kernel.org/r/20250709182843.35812-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20250704221408.38510-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: kernel test robot <lkp@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/trace/events/damon.h
mm/damon/core.c

index 32c6110760236fb16bf99137d91ee7d42a51ef4a..852d725afea2ff53b3d3fb1c00fd9d3879273972 100644 (file)
@@ -9,6 +9,30 @@
 #include <linux/types.h>
 #include <linux/tracepoint.h>
 
+TRACE_EVENT(damos_esz,
+
+       TP_PROTO(unsigned int context_idx, unsigned int scheme_idx,
+               unsigned long esz),
+
+       TP_ARGS(context_idx, scheme_idx, esz),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, context_idx)
+               __field(unsigned int, scheme_idx)
+               __field(unsigned long, esz)
+       ),
+
+       TP_fast_assign(
+               __entry->context_idx = context_idx;
+               __entry->scheme_idx = scheme_idx;
+               __entry->esz = esz;
+       ),
+
+       TP_printk("ctx_idx=%u scheme_idx=%u esz=%lu",
+                       __entry->context_idx, __entry->scheme_idx,
+                       __entry->esz)
+);
+
 TRACE_EVENT_CONDITION(damos_before_apply,
 
        TP_PROTO(unsigned int context_idx, unsigned int scheme_idx,
index 57a1ace4d10dfb57436b011adb4bc9ef50600454..e8036254cc987c30c4043279f27dece1cc7c3777 100644 (file)
@@ -2011,12 +2011,26 @@ static void damos_set_effective_quota(struct damos_quota *quota)
        quota->esz = esz;
 }
 
+static void damos_trace_esz(struct damon_ctx *c, struct damos *s,
+               struct damos_quota *quota)
+{
+       unsigned int cidx = 0, sidx = 0;
+       struct damos *siter;
+
+       damon_for_each_scheme(siter, c) {
+               if (siter == s)
+                       break;
+               sidx++;
+       }
+       trace_damos_esz(cidx, sidx, quota->esz);
+}
+
 static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
 {
        struct damos_quota *quota = &s->quota;
        struct damon_target *t;
        struct damon_region *r;
-       unsigned long cumulated_sz;
+       unsigned long cumulated_sz, cached_esz;
        unsigned int score, max_score = 0;
 
        if (!quota->ms && !quota->sz && list_empty(&quota->goals))
@@ -2030,7 +2044,11 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
                quota->total_charged_sz += quota->charged_sz;
                quota->charged_from = jiffies;
                quota->charged_sz = 0;
+               if (trace_damos_esz_enabled())
+                       cached_esz = quota->esz;
                damos_set_effective_quota(quota);
+               if (trace_damos_esz_enabled() && quota->esz != cached_esz)
+                       damos_trace_esz(c, s, quota);
        }
 
        if (!c->ops.get_scheme_score)