All of lore.kernel.org
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: [RFC PATCH v1.1 03/11] mm/damon/core: make damon_stop() never fails
Date: Sun,  5 Jul 2026 09:01:30 -0700	[thread overview]
Message-ID: <20260705160142.97308-4-sj@kernel.org> (raw)
In-Reply-To: <20260705160142.97308-1-sj@kernel.org>

damon_stop() has no reason to fail.  It returns an error code only for
possible future changes that can make it fail.  Such a change has not
been made yet, and this only makes the error handling complicated and
confusing.  Ensure it returns no error.

Signed-off-by: SJ Park <sj@kernel.org>
---
 mm/damon/core.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index d89a7f2faf350..84e400aa4e823 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1926,10 +1926,8 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive)
 /*
  * __damon_stop() - Stops monitoring of a given context.
  * @ctx:	monitoring context
- *
- * Return: 0 on success, negative error code otherwise.
  */
-static int __damon_stop(struct damon_ctx *ctx)
+static void __damon_stop(struct damon_ctx *ctx)
 {
 	struct task_struct *tsk;
 
@@ -1939,31 +1937,24 @@ static int __damon_stop(struct damon_ctx *ctx)
 		get_task_struct(tsk);
 		mutex_unlock(&ctx->kdamond_lock);
 		kthread_stop_put(tsk);
-		return 0;
+		return;
 	}
 	mutex_unlock(&ctx->kdamond_lock);
-
-	return -EPERM;
 }
 
 /**
  * damon_stop() - Stops the monitorings for a given group of contexts.
  * @ctxs:	an array of the pointers for contexts to stop monitoring
  * @nr_ctxs:	size of @ctxs
- *
- * Return: 0 on success, negative error code otherwise.
  */
 int damon_stop(struct damon_ctx **ctxs, int nr_ctxs)
 {
-	int i, err = 0;
+	int i;
 
-	for (i = 0; i < nr_ctxs; i++) {
+	for (i = 0; i < nr_ctxs; i++)
 		/* nr_running_ctxs is decremented in kdamond_fn */
-		err = __damon_stop(ctxs[i]);
-		if (err)
-			break;
-	}
-	return err;
+		__damon_stop(ctxs[i]);
+	return 0;
 }
 
 /**
-- 
2.47.3

  parent reply	other threads:[~2026-07-05 16:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 16:01 [RFC PATCH v1.1 00/11] mm/damon: refactor damon_{start,stop,commit}() for simple error handling SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 01/11] mm/damon/core: stop ctxs in damon_start() before returning an error SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 02/11] samples/damon/mtier: do not stop first context for damon_start() failure SJ Park
2026-07-05 16:01 ` SJ Park [this message]
2026-07-05 16:01 ` [RFC PATCH v1.1 04/11] mm/damon/sysfs: ignore damon_stop() return value SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 05/11] mm/damon/reclaaim: " SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 06/11] mm/damon/lru_sort: " SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 07/11] mm/damon/core: change damon_stop() return type to void SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 08/11] samples/damon/mtier: stop all contexts with single damon_stop() call SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 09/11] mm/damon/core: wait ctx stop in damon_call() before reruning an error SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 10/11] samples/damon/wsse: do not stop ctx for damon_call() failure SJ Park
2026-07-05 16:01 ` [RFC PATCH v1.1 11/11] samples/damon/prcl: do not stop DAMON " SJ 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=20260705160142.97308-4-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --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.