summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorWang Guangke <gkwang@linx-info.com>2026-11-09 16:48:14 -0800
committerAndrew Morton <akpm@linux-foundation.org>2026-11-22 22:24:09 -0800
commitdedc63739690f130e19d7ff10945cdd54a9dc30f (patch)
treecb56b01fb10995a8cd50aecb888f255e77c091a2 /tools/perf/scripts/python
parent2ec6ad932675db84a55d0bce7543e80c5ba8351c (diff)
mm/damon/stat: avoid overflow in estimated_memory_bandwidth calculation
estimated_memory_bandwidth is calculated by access_bytes * USEC_PER_MSEC * MSEC_PER_SEC (= USEC_PER_SEC) / aggr_interval, and users read it via /sys/module/damon_stat/parameters/estimated_memory_bandwidth. On 32-bit systems, access_bytes * USEC_PER_SEC overflows unsigned long once access_bytes exceeds about 4294 (U32_MAX / USEC_PER_SEC), so users get a wrong value. Fix it by doing the calculation in 64-bit and splitting the division into quotient and remainder. The issue was reproduced on a 32-bit system (qemu-system-i386): the parameter estimated_memory_bandwidth reported 362 instead of the expected 1926150; with the fix, the value matches the expectation. Link: https://patch.msgid.link/20261110004816.100066-1-sj@kernel.org Fixes: fabdd1e911da ("mm/damon/stat: calculate and expose estimated memory bandwidth") Signed-off-by: Wang Guangke <gkwang@linx-info.com> Signed-off-by: SJ Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: SJ Park <sj@kernel.org> Cc: <stable@vger.kernel.org> mm/damon/stat.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions