Skip to content

Commit 8b40db0

Browse files
sjp38akpm00
authored andcommitted
mm/damon/sysfs: remove damon_sysfs_cmd_request code from damon_sysfs_handle_cmd()
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 client code in damon_sysfs_andle_cmd() does nothing in real. Remove the unnecessary code. Link: https://lkml.kernel.org/r/20250306175908.66300-6-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 3301f18 commit 8b40db0

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

mm/damon/sysfs.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,8 +1715,6 @@ static int damon_sysfs_update_schemes_tried_regions(
17151715
static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
17161716
struct damon_sysfs_kdamond *kdamond)
17171717
{
1718-
bool need_wait = true;
1719-
17201718
switch (cmd) {
17211719
case DAMON_SYSFS_CMD_ON:
17221720
return damon_sysfs_turn_damon_on(kdamond);
@@ -1747,38 +1745,8 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
17471745
return damon_sysfs_damon_call(
17481746
damon_sysfs_upd_tuned_intervals, kdamond);
17491747
default:
1750-
break;
1751-
}
1752-
1753-
/* Pass the command to DAMON callback for safe DAMON context access */
1754-
if (damon_sysfs_cmd_request.kdamond)
1755-
return -EBUSY;
1756-
if (!damon_sysfs_kdamond_running(kdamond))
17571748
return -EINVAL;
1758-
damon_sysfs_cmd_request.cmd = cmd;
1759-
damon_sysfs_cmd_request.kdamond = kdamond;
1760-
1761-
/*
1762-
* wait until damon_sysfs_cmd_request_callback() handles the request
1763-
* from kdamond context
1764-
*/
1765-
mutex_unlock(&damon_sysfs_lock);
1766-
while (need_wait) {
1767-
schedule_timeout_idle(msecs_to_jiffies(100));
1768-
if (!mutex_trylock(&damon_sysfs_lock))
1769-
continue;
1770-
if (!damon_sysfs_cmd_request.kdamond) {
1771-
/* damon_sysfs_cmd_request_callback() handled */
1772-
need_wait = false;
1773-
} else if (!damon_sysfs_kdamond_running(kdamond)) {
1774-
/* kdamond has already finished */
1775-
need_wait = false;
1776-
damon_sysfs_cmd_request.kdamond = NULL;
1777-
}
1778-
mutex_unlock(&damon_sysfs_lock);
17791749
}
1780-
mutex_lock(&damon_sysfs_lock);
1781-
return 0;
17821750
}
17831751

17841752
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,

0 commit comments

Comments
 (0)