Re: [PATCH v3 2/2] mm/damon/core: eliminate hot-path integer division in damon_max_nr_accesses()
From: SeongJae Park
Date: Mon Mar 23 2026 - 10:28:18 EST
On Sun, 22 Mar 2026 21:43:25 +0000 Josh Law <objecting@xxxxxxxxxxxxx> wrote:
> Hardware integer division is slow. The function damon_max_nr_accesses(),
> which is called very frequently (e.g., once per region per sample
> interval inside damon_update_region_access_rate), performs an integer
> division: attrs->aggr_interval / attrs->sample_interval.
>
> However, the struct damon_attrs already caches this exact ratio in the
> internal field aggr_samples (since earlier commits). We can eliminate
> the hardware division in the hot path by simply returning aggr_samples.
>
> This significantly reduces the CPU cycle overhead of updating the access
> rates for thousands of regions.
>
> Signed-off-by: Josh Law <objecting@xxxxxxxxxxxxx>
Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>
Thanks,
SJ
[...]