mm/damon/sysfs-schemes: implement a command for scheme quota goals only commit
To update DAMOS quota goals, users need to enter 'commit' command to the 'state' file of the kdamond, which applies not only the goals but entire inputs. It is inefficient. Implement yet another 'state' file input command for reading and committing only the scheme quota goals, namely 'commit_schemes_quota_goals'. Link: https://lkml.kernel.org/r/20231130023652.50284-5-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Brendan Higgins <brendanhiggins@google.com> Cc: David Gow <davidgow@google.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
8b549a4fd3
commit
d91beaa505
@ -56,3 +56,6 @@ int damon_sysfs_schemes_update_regions_stop(struct damon_ctx *ctx);
|
||||
int damon_sysfs_schemes_clear_regions(
|
||||
struct damon_sysfs_schemes *sysfs_schemes,
|
||||
struct damon_ctx *ctx);
|
||||
|
||||
void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes,
|
||||
struct damon_ctx *ctx);
|
||||
|
@ -1896,6 +1896,22 @@ static void damos_sysfs_set_quota_score(
|
||||
}
|
||||
}
|
||||
|
||||
void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes,
|
||||
struct damon_ctx *ctx)
|
||||
{
|
||||
struct damos *scheme;
|
||||
int i = 0;
|
||||
|
||||
damon_for_each_scheme(scheme, ctx) {
|
||||
struct damon_sysfs_scheme *sysfs_scheme;
|
||||
|
||||
sysfs_scheme = sysfs_schemes->schemes_arr[i];
|
||||
damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals,
|
||||
&scheme->quota);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static struct damos *damon_sysfs_mk_scheme(
|
||||
struct damon_sysfs_scheme *sysfs_scheme)
|
||||
{
|
||||
|
@ -994,6 +994,11 @@ enum damon_sysfs_cmd {
|
||||
DAMON_SYSFS_CMD_OFF,
|
||||
/* @DAMON_SYSFS_CMD_COMMIT: Update kdamond inputs. */
|
||||
DAMON_SYSFS_CMD_COMMIT,
|
||||
/*
|
||||
* @DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS: Commit the quota goals
|
||||
* to DAMON.
|
||||
*/
|
||||
DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS,
|
||||
/*
|
||||
* @DAMON_SYSFS_CMD_UPDATE_SCHEMES_STATS: Update scheme stats sysfs
|
||||
* files.
|
||||
@ -1025,6 +1030,7 @@ static const char * const damon_sysfs_cmd_strs[] = {
|
||||
"on",
|
||||
"off",
|
||||
"commit",
|
||||
"commit_schemes_quota_goals",
|
||||
"update_schemes_stats",
|
||||
"update_schemes_tried_bytes",
|
||||
"update_schemes_tried_regions",
|
||||
@ -1351,6 +1357,24 @@ static int damon_sysfs_commit_input(struct damon_sysfs_kdamond *kdamond)
|
||||
kdamond->contexts->contexts_arr[0]);
|
||||
}
|
||||
|
||||
static int damon_sysfs_commit_schemes_quota_goals(
|
||||
struct damon_sysfs_kdamond *sysfs_kdamond)
|
||||
{
|
||||
struct damon_ctx *ctx;
|
||||
struct damon_sysfs_context *sysfs_ctx;
|
||||
|
||||
if (!damon_sysfs_kdamond_running(sysfs_kdamond))
|
||||
return -EINVAL;
|
||||
/* TODO: Support multiple contexts per kdamond */
|
||||
if (sysfs_kdamond->contexts->nr != 1)
|
||||
return -EINVAL;
|
||||
|
||||
ctx = sysfs_kdamond->damon_ctx;
|
||||
sysfs_ctx = sysfs_kdamond->contexts->contexts_arr[0];
|
||||
damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* damon_sysfs_cmd_request_callback() - DAMON callback for handling requests.
|
||||
* @c: The DAMON context of the callback.
|
||||
@ -1379,6 +1403,9 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c, bool active)
|
||||
case DAMON_SYSFS_CMD_COMMIT:
|
||||
err = damon_sysfs_commit_input(kdamond);
|
||||
break;
|
||||
case DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS:
|
||||
err = damon_sysfs_commit_schemes_quota_goals(kdamond);
|
||||
break;
|
||||
case DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_BYTES:
|
||||
total_bytes_only = true;
|
||||
fallthrough;
|
||||
|
Loading…
Reference in New Issue
Block a user