Re: [PATCH 05/12] mm/damon/sysfs: remove probes number validation
From: Kunwu Chan
Date: Wed Sep 02 2026 - 10:40:20 EST
On Tue, 1 Sep 2026 22:47:38 -0700 SJ Park <sj@xxxxxxxxxx> wrote:
> DAMON sysfs interface is disallowing >DAMON_MAX_PROBES nr_probes input,
> since DAMON_MAX_PROBES is the upper limit of probes per DAMON context.
> The core layer is validating the upper limit again, though. It is
> preferred to let DAMON API callers such as sysfs interface to set
> parameters in flexible ways, and do parameters validation in the core
> layer. Drop the duplicated validation in the sysfs interface.
>
> Signed-off-by: SJ Park <sj@xxxxxxxxxx>
> ---
> mm/damon/sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index 7ec14f48d157a..b576e97cbfdb8 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -1479,7 +1479,7 @@ static ssize_t nr_probes_store(struct kobject *kobj,
>
> if (err)
> return err;
> - if (nr < 0 || nr > DAMON_MAX_PROBES)
> + if (nr < 0)
Hi SJ,
Thanks for the cleanup.
I was wondering whether DAMON_MAX_PROBES is purely a core invariant
or also an interface constraint.
With this change, sysfs allows nr_probes larger than
DAMON_MAX_PROBES and damon_sysfs_probes_add_dirs() will start creating
probe objects before the configuration is later rejected by
damon_valid_probe_params().
Since nr_probes directly controls the number of sysfs objects created,
do we still want to keep an early check here?
I agree that the core validation is required for non-sysfs callers,
but I am not sure whether this particular limit should be duplicated
at the sysfs layer.
Thanks,
Kunwu
> return -EINVAL;
>
> probes = container_of(kobj, struct damon_sysfs_probes, kobj);
> --
> 2.47.3
>
Sent using hkml (https://github.com/sjp38/hackermail)