Re: [RFC PATCH 02/10] mm/damon/core: add damon_new_region() debug_sanity check
From: SeongJae Park
Date: Sun Mar 01 2026 - 11:33:55 EST
On Sat, 21 Feb 2026 11:36:19 -0800 SeongJae Park <sj@xxxxxxxxxx> wrote:
> damon_new_region() is supposed to be called with only valid address
> range arguments. Do the check under DAMON_DEBUG_SANITY.
>
> Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
> ---
> mm/damon/core.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 602b85ef23597..a7f5748c1fe17 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -109,6 +109,22 @@ int damon_select_ops(struct damon_ctx *ctx, enum damon_ops_id id)
> return err;
> }
>
> +#ifdef CONFIG_DAMON_DEBUG_SANITY
> +static void damon_verify_new_region(unsigned long start, unsigned long end)
> +{
> +
I'll remove the above unnecessary new line in the next spin.
> + if (start < end)
> + return;
> + pr_err("damon_new_region() s called with start %lu >= end %lu!\n",
> + start, end);
> + WARN_ONCE();
> +}
> +#else
> +static void damon_verify_new_region(unsigned long start, unsigned long end)
> +{
> +}
> +#endif
> +
> /*
> * Construct a damon_region struct
> *
> @@ -122,6 +138,8 @@ struct damon_region *damon_new_region(unsigned long start, unsigned long end)
> if (!region)
> return NULL;
>
> + damon_verify_new_region(start, end);
> +
The verification may better to be made before the above region allocation.
I'll move it to the beginning of this function in the next spin.
> region->ar.start = start;
> region->ar.end = end;
> region->nr_accesses = 0;
> --
> 2.47.3
Thanks,
SJ