mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] mm/damon/sysfs: propagate damon_call() error in turn_damon_on
@ 2026-09-15  9:39 Xuewen Wang
  2026-09-15 15:05 ` SJ Park
  0 siblings, 1 reply; 2+ messages in thread
From: Xuewen Wang @ 2026-09-15  9:39 UTC (permalink / raw)
  To: sj, akpm; +Cc: damon, linux-mm, linux-kernel, Xuewen Wang

damon_sysfs_turn_damon_on() ignored the return value of damon_call()
for the repeat call control registration and always returned the stale
result of damon_start() (0 at that point). When damon_call() fails,
e.g., the kdamond is already exiting, the user still gets success from
the state file write while monitoring is not actually on.

Save and return the damon_call() result instead. No rollback of
damon_start() is needed since a failed damon_call() guarantees the
context is stopped.

Signed-off-by: Xuewen Wang <wangxuewen@kylinos.cn>
---
 mm/damon/sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index e3858ffab4b2..beb4bdc74460 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -2280,7 +2280,8 @@ static int damon_sysfs_turn_damon_on(struct damon_sysfs_kdamond *kdamond)
 	repeat_call_control->data = kdamond;
 	repeat_call_control->repeat = true;
 	repeat_call_control->dealloc_on_cancel = true;
-	if (damon_call(ctx, repeat_call_control))
+	err = damon_call(ctx, repeat_call_control);
+	if (err)
 		kfree(repeat_call_control);
 	return err;
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] mm/damon/sysfs: propagate damon_call() error in turn_damon_on
  2026-09-15  9:39 [PATCH v1] mm/damon/sysfs: propagate damon_call() error in turn_damon_on Xuewen Wang
@ 2026-09-15 15:05 ` SJ Park
  0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-09-15 15:05 UTC (permalink / raw)
  To: Xuewen Wang; +Cc: SJ Park, akpm, damon, linux-mm, linux-kernel

On Tue, 15 Sep 2026 17:39:28 +0800 Xuewen Wang <wangxuewen@kylinos.cn> wrote:

> damon_sysfs_turn_damon_on() ignored the return value of damon_call()
> for the repeat call control registration and always returned the stale
> result of damon_start() (0 at that point). When damon_call() fails,
> e.g., the kdamond is already exiting, the user still gets success from
> the state file write while monitoring is not actually on.
> 
> Save and return the damon_call() result instead. No rollback of
> damon_start() is needed since a failed damon_call() guarantees the
> context is stopped.

Nice catch, thank you for fixing this!
> 
> Signed-off-by: Xuewen Wang <wangxuewen@kylinos.cn>

Reviewed-by: SJ Park <sj@kernel.org>

This patch is applied to damon/next [1] tree.  If this patch is not added to
mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton)
to pick this.  So, no action from your side is needed for now.  If it seems I
also forgot doing that or you cannot wait for my action, please feel free to
directly ask that to Andrew.

[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees


Thanks,
SJ

[...]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-15 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15  9:39 [PATCH v1] mm/damon/sysfs: propagate damon_call() error in turn_damon_on Xuewen Wang
2026-09-15 15:05 ` SJ Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®