Re: [RFC PATCH -next 07/16] mm/damon/sysfs: implement addr_unit file under context dir

From: Quanmin Yan
Date: Tue Aug 19 2025 - 10:48:45 EST


Hi SJ,

在 2025/8/19 14:24, SeongJae Park 写道:
Hi Quanmin,

As I suggested on another reply[1], please squash attaching patch to this one
when you post next version of this series.

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

[...]


Thanks,
SJ

==== Attachment 0 (0001-mm-damon-sysfs-return-EINVAL-for-zero-addr_unit.patch) ====
From e0a5aa5e571ecd0f58b0914f8fc8562a60014ae8 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@xxxxxxxxxx>
Date: Wed, 13 Aug 2025 21:17:03 -0700
Subject: [PATCH] mm/damon/sysfs: return -EINVAL for zero addr_unit

Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/damon/sysfs.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index bea782b0a711..eb4269383bae 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1422,6 +1422,8 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx,
err = damon_select_ops(ctx, sys_ctx->ops_id);
if (err)
return err;
+ if (!sys_ctx->addr_unit)
+ return -EINVAL;
ctx->addr_unit = sys_ctx->addr_unit;
err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs);
if (err)

Aha, returning -EINVAL when sys_ctx->addr_unit is 0 makes sense, but I wonder if it
might be better to prevent users from inputting 0 at the source instead? I've attempted
to modify patch 7 by adding a check in addr_unit_store. I'll send out the v2 version
of patch 7 later (PS: I am performing a comprehensive validation of the v2 patch series),
and we can discuss it then.

Thanks,
Quanmin Yan