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 05/13] mm/damon/sysfs: remove damon_sysfs_cmd_request code from damon_sysfs_handle_cmd()
Date: Tue, 25 Feb 2025 22:36:43 -0800	[thread overview]
Message-ID: <20250226063651.513178-6-sj@kernel.org> (raw)
In-Reply-To: <20250226063651.513178-1-sj@kernel.org>

damon_sysfs_handle_cmd() handles user requests that it can directly
handle on its own.  For requests that need to be handled from
damon_callback hooks, it uses DAMON sysfs interface's own synchronous
damon_callback hooks management mechanism, namely
damon_sysfs_cmd_request.  Now all user requests are handled without
damon_callback hooks, so damon_sysfs_cmd_request use code in
damon_sysfs_andle_cmd() does nothing in real.  Remove the unnecessary
code.

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

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index c55a2cee4b74..166161f12c26 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1715,8 +1715,6 @@ static int damon_sysfs_update_schemes_tried_regions(
 static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
 		struct damon_sysfs_kdamond *kdamond)
 {
-	bool need_wait = true;
-
 	switch (cmd) {
 	case DAMON_SYSFS_CMD_ON:
 		return damon_sysfs_turn_damon_on(kdamond);
@@ -1747,38 +1745,8 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
 		return damon_sysfs_damon_call(
 				damon_sysfs_upd_tuned_intervals, kdamond);
 	default:
-		break;
-	}
-
-	/* Pass the command to DAMON callback for safe DAMON context access */
-	if (damon_sysfs_cmd_request.kdamond)
-		return -EBUSY;
-	if (!damon_sysfs_kdamond_running(kdamond))
 		return -EINVAL;
-	damon_sysfs_cmd_request.cmd = cmd;
-	damon_sysfs_cmd_request.kdamond = kdamond;
-
-	/*
-	 * wait until damon_sysfs_cmd_request_callback() handles the request
-	 * from kdamond context
-	 */
-	mutex_unlock(&damon_sysfs_lock);
-	while (need_wait) {
-		schedule_timeout_idle(msecs_to_jiffies(100));
-		if (!mutex_trylock(&damon_sysfs_lock))
-			continue;
-		if (!damon_sysfs_cmd_request.kdamond) {
-			/* damon_sysfs_cmd_request_callback() handled */
-			need_wait = false;
-		} else if (!damon_sysfs_kdamond_running(kdamond)) {
-			/* kdamond has already finished */
-			need_wait = false;
-			damon_sysfs_cmd_request.kdamond = NULL;
-		}
-		mutex_unlock(&damon_sysfs_lock);
 	}
-	mutex_lock(&damon_sysfs_lock);
-	return 0;
 }
 
 static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
-- 
2.39.5


  parent reply	other threads:[~2025-02-26  6:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26  6:36 [RFC PATCH 00/13] mm/damon/sysfs: commit parameters online via damon_call() SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 01/13] mm/damon/sysfs: validate user inputs from damon_sysfs_commit_input() SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 02/13] mm/damon/core: invoke kdamond_call() after merging is done if possible SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 03/13] mm/damon/core: make damon_set_attrs() be safe to be called from damon_call() SeongJae Park
2025-03-02 21:41   ` SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 04/13] mm/damon/sysfs: handle commit command using damon_call() SeongJae Park
2025-02-26  6:36 ` SeongJae Park [this message]
2025-02-26  6:36 ` [RFC PATCH 06/13] mm/damon/sysfs: remove damon_sysfs_cmd_request_callback() and its callers SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 07/13] mm/damon/sysfs: remove damon_sysfs_cmd_request and its readers SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 08/13] mm/damon/sysfs-schemes: remove obsolete comment for damon_sysfs_schemes_clear_regions() SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 09/13] mm/damon: remove damon_callback->private SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 10/13] mm/damon: remove ->before_start of damon_callback SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 11/13] mm/damon: remove damon_callback->after_sampling SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 12/13] mm/damon: remove damon_callback->before_damos_apply SeongJae Park
2025-02-26  6:36 ` [RFC PATCH 13/13] mm/damon: remove damon_operations->reset_aggregated 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=20250226063651.513178-6-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