damon_nr_accesses_mvsum() returns a value same to nr_accesses_bp.  Also
the function is more simple and therefore more tolerant to errors.
Execution of the function would be more expensive than the simple read
of the field, but because the function is quite simple, the overhead
should be negligible.  Use it in the DAMON region exporting trace points
instead of the nr_accesses_bp.

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

diff --git a/include/trace/events/damon.h b/include/trace/events/damon.h
index 78388538acf44..8851727ae1627 100644
--- a/include/trace/events/damon.h
+++ b/include/trace/events/damon.h
@@ -78,9 +78,11 @@ TRACE_EVENT_CONDITION(damos_before_apply,
 
        TP_PROTO(unsigned int context_idx, unsigned int scheme_idx,
                unsigned int target_idx, struct damon_region *r,
-               unsigned int nr_regions, bool do_trace),
+               unsigned int nr_accesses, unsigned int nr_regions,
+               bool do_trace),
 
-       TP_ARGS(context_idx, scheme_idx, target_idx, r, nr_regions, do_trace),
+       TP_ARGS(context_idx, scheme_idx, target_idx, r, nr_accesses,
+               nr_regions, do_trace),
 
        TP_CONDITION(do_trace),
 
@@ -101,7 +103,7 @@ TRACE_EVENT_CONDITION(damos_before_apply,
                __entry->target_idx = target_idx;
                __entry->start = r->ar.start;
                __entry->end = r->ar.end;
-               __entry->nr_accesses = r->nr_accesses_bp / 10000;
+               __entry->nr_accesses = nr_accesses;
                __entry->age = r->age;
                __entry->nr_regions = nr_regions;
        ),
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3a6df10ba8548..2eddf2674f4fa 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2463,6 +2463,7 @@ static void damos_apply_scheme(struct damon_ctx *c, 
struct damon_target *t,
                        return;
                ktime_get_coarse_ts64(&begin);
                trace_damos_before_apply(cidx, sidx, tidx, r,
+                               damon_nr_accesses_mvsum(r, c),
                                damon_nr_regions(t), do_trace);
                sz_applied = c->ops.apply_scheme(c, t, r, s,
                                &sz_ops_filter_passed);
-- 
2.47.3

Reply via email to