From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SJ Park <sj@kernel.org>,
damon@lists.linux.dev, linux-mm@kvack.org,
Enze Li <lienze@kylinos.cn>, Lian Wang <lianux.mm@gmail.com>
Subject: [PATCH 2/4] mm/damon/sysfs: use damon_sysfs_cmd_names in state_store()
Date: Sun, 29 Nov 2026 11:01:49 -0800 [thread overview]
Message-ID: <20261129190152.89889-3-sj@kernel.org> (raw)
In-Reply-To: <20261129190152.89889-1-sj@kernel.org>
Update kdamond state file write handling function to use
damon_sysfs_cmd_names instead of damon_sysfs_cmd_strs.
Reviewed-by: Enze Li <lienze@kylinos.cn>
Reviewed-by: Lian Wang <lianux.mm@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
---
mm/damon/sysfs.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index c76063b703a4..e0ddf4ed5dbb 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -2848,14 +2848,17 @@ static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
{
struct damon_sysfs_kdamond *kdamond = container_of(kobj,
struct damon_sysfs_kdamond, kobj);
- enum damon_sysfs_cmd cmd;
ssize_t ret = -EINVAL;
+ int i;
if (!mutex_trylock(&damon_sysfs_lock))
return -EBUSY;
- for (cmd = 0; cmd < NR_DAMON_SYSFS_CMDS; cmd++) {
- if (sysfs_streq(buf, damon_sysfs_cmd_strs[cmd])) {
- ret = damon_sysfs_handle_cmd(cmd, kdamond);
+ for (i = 0; i < ARRAY_SIZE(damon_sysfs_cmd_names); i++) {
+ const struct damon_sysfs_cmd_name *cmd_name;
+
+ cmd_name = &damon_sysfs_cmd_names[i];
+ if (sysfs_streq(buf, cmd_name->name)) {
+ ret = damon_sysfs_handle_cmd(cmd_name->cmd, kdamond);
break;
}
}
--
2.47.3
next prev parent reply other threads:[~2026-11-29 19:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 19:01 [PATCH 0/4] mm/damon/sysfs: refactor state input matching SJ Park
2026-11-29 19:01 ` [PATCH 1/4] mm/damon/sysfs: define damon_sysfs_cmd_name type and array SJ Park
2026-11-29 20:24 ` + mm-damon-sysfs-define-damon_sysfs_cmd_name-type-and-array.patch added to mm-unstable branch Andrew Morton
2026-11-29 19:01 ` SJ Park [this message]
2026-11-29 20:24 ` + mm-damon-sysfs-use-damon_sysfs_cmd_names-in-state_store.patch " Andrew Morton
2026-11-29 19:01 ` [PATCH 3/4] mm/damon/sysfs: use damon_sysfs_cmd_names in state_show() SJ Park
2026-11-29 20:24 ` + mm-damon-sysfs-use-damon_sysfs_cmd_names-in-state_show.patch added to mm-unstable branch Andrew Morton
2026-11-29 19:01 ` [PATCH 4/4] mm/damon/sysfs: remove damon_sysfs_cmd_strs and NR_DAMON_SYSFS_CMDS SJ Park
2026-11-29 20:24 ` + mm-damon-sysfs-remove-damon_sysfs_cmd_strs-and-nr_damon_sysfs_cmds.patch added to mm-unstable branch Andrew Morton
2026-11-29 19:09 ` [PATCH 0/4] mm/damon/sysfs: refactor state input matching sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261129190152.89889-3-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=lianux.mm@gmail.com \
--cc=lienze@kylinos.cn \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.