summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSJ Park <sj@kernel.org>2026-07-08 06:53:57 -0700
committerAndrew Morton <akpm@linux-foundation.org>2026-08-04 19:18:44 -0700
commitd59bf2653c15be215257de936da357d7a40ba749 (patch)
tree03ef70f2d660a23c08dfde18647e38e27ff1afc1
parente06b7f0cf8c88c582558839c853689cb3cbdf25b (diff)
downloadlinux-d59bf2653c15be215257de936da357d7a40ba749.tar.gz
linux-d59bf2653c15be215257de936da357d7a40ba749.zip
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 <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--mm/damon/core.c3
1 files changed, 3 insertions, 0 deletions
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);
}