linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
Cc: SeongJae Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	damon@lists.linux.dev, kernel-team@meta.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [RFC PATCH 11/14] mm/damon/sysfs: remove damon_sysfs_destroy_targets()
Date: Sun,  6 Jul 2025 13:00:15 -0700	[thread overview]
Message-ID: <20250706200018.42704-12-sj@kernel.org> (raw)
In-Reply-To: <20250706200018.42704-1-sj@kernel.org>

The function was introduced for putting pids and deallocating
unnecessary targets.  Hence it is called before damon_destroy_ctx().
Now vaddr puts pid for each target destruction (cleanup_target()).
damon_destroy_ctx() deallocates the targets anyway.  So
damon_sysfs_destroy_targets() has no reason to exist.  Remove it.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 5eba6ac53939..b0f7c60d655a 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1295,14 +1295,6 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
 	return damon_set_attrs(ctx, &attrs);
 }
 
-static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
-{
-	struct damon_target *t, *next;
-
-	damon_for_each_target_safe(t, next, ctx)
-		damon_destroy_target(t, ctx);
-}
-
 static int damon_sysfs_set_regions(struct damon_target *t,
 		struct damon_sysfs_regions *sysfs_regions)
 {
@@ -1337,7 +1329,6 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target,
 		struct damon_ctx *ctx)
 {
 	struct damon_target *t = damon_new_target();
-	int err = -EINVAL;
 
 	if (!t)
 		return -ENOMEM;
@@ -1345,16 +1336,10 @@ static int damon_sysfs_add_target(struct damon_sysfs_target *sys_target,
 	if (damon_target_has_pid(ctx)) {
 		t->pid = find_get_pid(sys_target->pid);
 		if (!t->pid)
-			goto destroy_targets_out;
+			/* caller will destroy targets */
+			return -EINVAL;
 	}
-	err = damon_sysfs_set_regions(t, sys_target->regions);
-	if (err)
-		goto destroy_targets_out;
-	return 0;
-
-destroy_targets_out:
-	damon_sysfs_destroy_targets(ctx);
-	return err;
+	return damon_sysfs_set_regions(t, sys_target->regions);
 }
 
 static int damon_sysfs_add_targets(struct damon_ctx *ctx,
@@ -1458,13 +1443,11 @@ static int damon_sysfs_commit_input(void *data)
 	test_ctx = damon_new_ctx();
 	err = damon_commit_ctx(test_ctx, param_ctx);
 	if (err) {
-		damon_sysfs_destroy_targets(test_ctx);
 		damon_destroy_ctx(test_ctx);
 		goto out;
 	}
 	err = damon_commit_ctx(kdamond->damon_ctx, param_ctx);
 out:
-	damon_sysfs_destroy_targets(param_ctx);
 	damon_destroy_ctx(param_ctx);
 	return err;
 }
-- 
2.39.5


  parent reply	other threads:[~2025-07-06 20:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-06 20:00 [RFC PATCH 00/14] mm/damon: remove damon_callback SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 01/14] mm/damon: accept parallel damon_call() requests SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 02/14] mm/damon/core: introduce repeat mode damon_call() SeongJae Park
2025-07-06 21:45   ` SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 03/14] mm/damon/stat: use damon_call() repeat mode instead of damon_callback SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 04/14] mm/damon/reclaim: " SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 05/14] mm/damon/lru_sort: " SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 06/14] samples/damon/prcl: " SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 07/14] samples/damon/wsse: " SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 08/14] mm/damon/core: do not call ops.cleanup() when destroying targets SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 09/14] mm/damon/core: add cleanup_target() ops callback SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 10/14] mm/damon/vaddr: put pid in cleanup_target() SeongJae Park
2025-07-06 21:48   ` SeongJae Park
2025-07-06 20:00 ` SeongJae Park [this message]
2025-07-06 20:00 ` [RFC PATCH 12/14] mm/damon/core: destroy targets when kdamond_fn() finish SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 13/14] mm/damon/sysfs: remove damon_sysfs_before_terminate() SeongJae Park
2025-07-06 20:00 ` [RFC PATCH 14/14] mm/damon/core: remove damon_callback 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=20250706200018.42704-12-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=kernel-team@meta.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).