Re: [PATCH 4/9] mm/damon/stat: avoid 32-bit overflow in idle percentiles
From: David Carlier
Date: Sat Nov 14 2026 - 13:10:46 EST
Hi SJ, Aveline,
The value stored a few lines below has the same problem on 32-bit:
damon_stat_idletime(region) *
(long)c->attrs.aggr_interval / USEC_PER_MSEC;
The product is the region's idle time in microseconds, held in a 32-bit
long, so it wraps once a region has been idle for more than about 36
minutes, whatever the intervals are. The cold-end percentiles then come
out negative or wrong. Doing the multiply in s64 with div_s64() would
keep the sign and avoid it.
Hope it helps !