Re: [PATCH] mm/damon/ops-common: fix age_in_sec overflow on 32-bit
From: SJ Park
Date: Wed Sep 30 2026 - 15:18:23 EST
Hi Jaeyeon,
On Wed, 30 Sep 2026 13:58:12 +0200 Jaeyeon Lee <jaeyeon.lee.dev@xxxxxxxxx> wrote:
> damon_hot_score() calculates the age of a region by multiplying r->age
> and the aggregation interval. On 32-bit architectures, unsigned long
> is 32 bits, so the multiplication overflows once the age exceeds about
> 4295 seconds. Then old regions are scored as if they were young.
>
> Fix it by doing the calculation in 64-bit arithmetic using div_u64().
> Also make age_in_sec u64, so the result is not truncated back to 32
> bits.
Looks reasonable to me. Thank you for this patch. I'm thinking about if there
is a simpler and more complete way to fix whole possible 32bit overflow issues,
but that shouldn't be a blocker of this patch.
>
> The issue was discovered [1] by Sashiko.
>
> [1] https://lore.kernel.org/20260623011652.1354-1-sj@xxxxxxxxxx
>
> Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization")
> Assisted-by: LLM
> Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@xxxxxxxxx>
Reviewed-by: SJ Park <sj@xxxxxxxxxx>
This patch is applied to damon/next [1] tree. If this patch is not added to
mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton)
to pick this. So, no action from your side is needed for now. If it seems I
also forgot doing that or you cannot wait for my action, please feel free to
ping me or Andrew.
[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees
Thanks,
SJ
[...]