Re: [PATCH] mm/damon/core: handle zero intervals in damon_max_nr_accesses()
From: SeongJae Park
Date: Sun Jun 21 2026 - 14:04:27 EST
On Sun, 21 Jun 2026 08:48:06 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:
> damon_max_nr_accesses() causes a divide-by-zero if the sampling interval
> is set to zero by the user. If the aggregation interval is set to zero,
> the function returns zero. It is wrong, since the real maximum
> nr_acceses in the setup should be one. Worse yet, it can cause another
> divide-by-zero from its caller, damon_hot_score(), since it uses
> damon_max_nr_accesses() return value as a denominator.
>
> Fix the problem by setting the denominator in the function as 1 when the
> sampling interval is zero. Also ensure the return value is always 1 or
> greater.
>
> The issue was discovered [1] by Sashiko.
>
> [1] https://lore.kernel.org/20260619202459.145010-1-sj@xxxxxxxxxx
>
> Fixes: 198f0f4c58b9 ("mm/damon/vaddr,paddr: support pageout prioritization")
Sashiko found [1] another bug that was introduced by another commit. I will
repost this patch with a fix for the another bug.
[1] https://lore.kernel.org/20260621175849.91990-1-sj@xxxxxxxxxx
Thanks,
SJ
[...]