[RFC PATCH v1.1 7/7] mm/damon/core: handle unreset probe_hits in probe_hits_mvsum()
From: SJ Park
Date: Tue Jul 07 2026 - 09:56:21 EST
If damon_update_monitoring_result() is called at the end of the
aggregation interval, probe_hits is not reset. That's because the value
will be exposed to the user via damon_region_aggregated trace event.
Meanwhile, damon_probe_hits_mvsum() can be called in this state. Due to
its logic, it will return a value that is incorrectly high. This could
happen if the user requested DAMOS schemes applied regions sysfs files
update exactly in the time sequence.
The impact is minor, but better to avoid. Check the timing and simply
return the fully aggregated last_probe_hits, like
damon_nr_accesses_mvsum() also does. It is not 100% accurate since it
is the last interval's aggregation. But better than the value that is
completely reset.
Signed-off-by: SJ Park <sj@xxxxxxxxxx>
---
mm/damon/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 9a3ff0fe55a61..093da5c0b3693 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -290,6 +290,9 @@ unsigned char damon_probe_hits_mvsum(int probe_idx, struct damon_region *r,
ctx->passed_sample_intervals;
left_window_bp = mult_frac(left_window, 10000, window_len);
+ if (left_window_bp == 10000)
+ return r->last_probe_hits[probe_idx];
+
return damon_mvsum(r->probe_hits[probe_idx],
r->last_probe_hits[probe_idx], left_window_bp);
}
--
2.47.3