Re: [PATCH 01/12] mm/damon/core: use damon_nr_samples_per_aggr() for max merge threshold

From: Kunwu Chan

Date: Wed Sep 02 2026 - 22:06:39 EST


On Tue, 1 Sep 2026 22:47:34 -0700 SJ Park <sj@xxxxxxxxxx> wrote:

> kdamond_merge_regions() open-codes max region merge threshold
> calculation. What it does is fundamentally the same as
> damon_nr_samples_per_aggr() but missing a few corner cases. The
> unhandled corner cases should be rare and make only a negligible level
> of monitoring results degradation. But having the inconsistency could
> increase future maintenance burden. Use the dedicated function.
>
> Signed-off-by: SJ Park <sj@xxxxxxxxxx>
> ---
> mm/damon/core.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index f748acd6bbd5b..846da6df5b552 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3509,8 +3509,7 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
> unsigned int max_thres;
> bool count_age = true;
>
> - max_thres = c->attrs.aggr_interval /
> - (c->attrs.sample_interval ? c->attrs.sample_interval : 1);
> + max_thres = damon_nr_samples_per_aggr(&c->attrs);

The helper replacement makes sense to me, and it also keeps
the corner-case handling centralized.


Reviewed-by: Kunwu Chan <kunwu.chan@xxxxxxxxx>

Thanks,
Kunwu


> while (true) {
> nr_regions = 0;
> damon_for_each_target(t, c) {
> --
> 2.47.3
>

Sent using hkml (https://github.com/sjp38/hackermail)