Re: [RFC PATCH -next 14/16] mm/damon/core: convert sz to byte units when updating state

From: SeongJae Park
Date: Wed Aug 13 2025 - 13:15:51 EST


On Wed, 13 Aug 2025 13:07:04 +0800 Quanmin Yan <yanquanmin1@xxxxxxxxxx> wrote:

> After introducing ctx->addr_unit, the unit of sz might not
> be in bytes. However, sz_applied is returned in bytes after
> processing by paddr.

This is not an intended behavior, but a bug of my code. Let's update patches
3-6 of this series to return sz_applied as core-layer address unit, instead of
bytes.

> To maintain external consistency, sz
> is converted to byte units when updating the state.

Users could keep the consistency by multiplying the addr_unit, which they set
themselves.

>
> Signed-off-by: Quanmin Yan <yanquanmin1@xxxxxxxxxx>
> ---
> mm/damon/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index b162aa1156fc..bc764f9dc5c5 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -1889,7 +1889,9 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
> r->age = 0;
>
> update_stat:
> - damos_update_stat(s, sz, sz_applied, sz_ops_filter_passed);
> + damos_update_stat(s,
> + sz * (c->ops.id == DAMON_OPS_PADDR ? c->addr_unit : 1),
> + sz_applied, sz_ops_filter_passed);
> }
>
> static void damon_do_apply_schemes(struct damon_ctx *c,
> --
> 2.34.1


Thanks,
SJ