Re: [PATCH 3/5] mm/damon/core: receive addr_unit on damon_set_region_biggest_system_ram_default()

From: SeongJae Park

Date: Fri Mar 13 2026 - 20:19:19 EST


On Tue, 10 Mar 2026 22:29:24 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:

> damon_find_biggest_system_ram() was not supporting addr_unit in the
> past. Hence, its caller, damon_set_region_biggest_system_ram_default(),
> was also not supporting addr_unit. The previous commit has updated the
> inner function to support addr_unit. There is no more reason to not
> support addr_unit on damon_set_region_biggest_system_ram_default().
> Rather, it makes unnecessary inconsistency on support of addr_unit.
> Update it to receive addr_unit and handle it inside.
>
> Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
> ---
> include/linux/damon.h | 1 +
> mm/damon/core.c | 7 ++++---
> mm/damon/lru_sort.c | 1 +
> mm/damon/reclaim.c | 1 +
> mm/damon/stat.c | 2 +-
> 5 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 1130c2f9a92f4..3a441fbca170d 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -988,6 +988,7 @@ int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control);
>
> int damon_set_region_biggest_system_ram_default(struct damon_target *t,
> unsigned long *start, unsigned long *end,
> + unsigned long addr_unit,
> unsigned long min_region_sz);
>
> #endif /* CONFIG_DAMON */
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index aee61bf991baa..d4f86c20b4f48 100644
[...]
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[...]
> @@ -3123,12 +3124,12 @@ int damon_set_region_biggest_system_ram_default(struct damon_target *t,
> return -EINVAL;
>
> if (!*start && !*end &&
> - !damon_find_biggest_system_ram(start, end, 1))
> + !damon_find_biggest_system_ram(start, end, addr_unit))
> return -EINVAL;
>
> addr_range.start = *start;
> addr_range.end = *end;
> - return damon_set_regions(t, &addr_range, 1, min_region_sz);
> + return damon_set_regions(t, &addr_range, addr_unit, min_region_sz);

The above line is unnecessarily and wrongly changing the third argument. It is
the number of ranges that passed by the second argument, never meant to be the
addr_unit.

A similar bug [1] was found by an AI review, and I found this patch also has a
similar bug.

Andrew, could you please add below attaching fixup?

[1] https://lore.kernel.org/20260313234026.48872-1-sj@xxxxxxxxxx


Thanks,
SJ

[...]
=== >8 ===