From d59bf2653c15be215257de936da357d7a40ba749 Mon Sep 17 00:00:00 2001 From: SJ Park Date: Wed, 8 Jul 2026 06:53:57 -0700 Subject: mm/damon/core: handle unreset probe_hits in probe_hits_mvsum() 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. Link: https://lore.kernel.org/20260708135359.122587-8-sj@kernel.org Signed-off-by: SJ Park Signed-off-by: Andrew Morton --- mm/damon/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index 15d31285515d..11473aa1f70f 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); } -- cgit v1.2.3