public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Liew Rui Yan <aethernet65535@gmail.com>
Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [RFC v2] mm/damon: add synchronous validation for commit_inputs
Date: Sat, 21 Mar 2026 10:32:34 -0700	[thread overview]
Message-ID: <20260321173235.84923-1-sj@kernel.org> (raw)
In-Reply-To: <20260321140926.22163-1-aethernet65535@gmail.com>

Hello Liew,

On Sat, 21 Mar 2026 22:09:26 +0800 Liew Rui Yan <aethernet65535@gmail.com> wrote:

> Problem
> =======
> Writing invalid parameters to sysfs followed by 'commit_inputs=Y' fails
> silently (no error returned to shell), because the validation happens
> aynchronously in the kdamond.
> 
> Solution
> ========
> To fix this, I proposed adding synchronous validation in
> damon_lru_sort_commit_inputs_store() and
> damon_reclaim_commit_inputs_store() before setting the 'commit_inputs'
> flag. This allow users to receive immediate feedback (e.g., -EINVAL) if
> the parameters are invalid.
> 
> Changes
> =======
> 1. Added damon_lru_sort_commit_inputs_store() and
>    damon_reclaim_commit_inputs_store() to handle parameter validation
>    before setting 'commit_inputs'.

Nice idea.  I think we could do even applying parameters in the callback.  It
could be something similar to what DAMON_SYSFS is doing.  The code path for
doing that in DAMON_SYSFS is, state_store() -> damon_sysfs_handle_cmd() ->
damon_sysfs_damon_call() -> damon_call() -> damon_sysfs_commit_input().  In the
damon_sysfs_commit_input(), you can show how DAMON_SYSFS validates input.  You
can also refer to commit 4c9ea539ad59 ("mm/damon/sysfs: validate user inputs
from damon_sysfs_commit_input()") for more details.

> 2. Added damon_validate_attrs() to centralize validation logic.

I think damon_commit_ctx() is a better way for validation.

> 
> This change is motivated from another discussion [1].
> 
> [1] https://lore.kernel.org/20260318153731.97470-1-aethernet65535@gmail.com
> 
> Signed-off-by: Liew Rui Yan <aethernet65535@gmail.com>

Because this is an RFC and I have a high level comment above, I'm skipping
detailed review of the code.


Thanks,
SJ

[...]


  parent reply	other threads:[~2026-03-21 17:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21 14:09 [RFC v2] mm/damon: add synchronous validation for commit_inputs Liew Rui Yan
2026-03-21 17:06 ` (Sashiko) " SeongJae Park
2026-03-21 17:40   ` SeongJae Park
2026-03-21 17:32 ` SeongJae Park [this message]
2026-03-22  6:06   ` Liew Rui Yan
2026-03-22 15:37     ` SeongJae Park

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=20260321173235.84923-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=aethernet65535@gmail.com \
    --cc=damon@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox