On Mon, 11 Sep 2023 16:51:44 -0400 Steven Rostedt <rostedt@xxxxxxxxxxx> wrote: > On Mon, 11 Sep 2023 20:36:42 +0000 > SeongJae Park <sj@xxxxxxxxxx> wrote: > > > > Then tracing is fully enabled here, and now we enter: > > > > > > if (trace_damos_before_apply_enabled()) { > > > trace_damos_before_apply(cidx, sidx, tidx, r, > > > damon_nr_regions(t)); > > > } > > > > > > Now the trace event is hit with sidx and tidx zero when they should not be. > > > This could confuse you when looking at the report. > > > > Thank you so much for enlightening me with this kind explanation, Steve! And > > this all make sense. I will follow your suggestion in the next spin. > > > > > > > > What I suggested was to initialize sidx to zero, > > > > Nit. Initialize to not zero but -1, right? > > Yeah, but I was also thinking of the reset of it too :-p > > sidx = -1; > > if (trace_damos_before_apply_enabled()) { > sidx = 0; Thank you for clarifying, Steve :) Nevertheless, since the variable is unsigned int, I would need to use UINT_MAX instead. To make the code easier to understand, I'd prefer to add a third parameter, as you suggested as another option at the original reply, like below: --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -997,6 +997,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, unsigned int sidx = 0; struct damon_target *titer; /* targets iterator */ unsigned int tidx = 0; + bool do_trace = false; /* get indices for trace_damos_before_apply() */ if (trace_damos_before_apply_enabled()) { @@ -1010,6 +1011,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, break; tidx++; } + do_trace = true; } if (c->ops.apply_scheme) { @@ -1036,7 +1038,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t, err = c->callback.before_damos_apply(c, t, r, s); if (!err) { trace_damos_before_apply(cidx, sidx, tidx, r, - damon_nr_regions(t)); + damon_nr_regions(t), do_trace); sz_applied = c->ops.apply_scheme(c, t, r, s); } ktime_get_coarse_ts64(&end); Thanks, SJ > > -- Steve > > > > > > > set it in the first trace_*_enabled() check, and ignore calling the > > > tracepoint if it's not >= 0. > > >