DAMON kernel API callers can show auto-tuned sampling and aggregation intervals from the monmitoring attributes data structure. That can be useful for debugging or tuning of the feature. DAMON user-space ABI users has no way to see that, though. Implement a new DAMON sysfs interface kdamond state command, namely 'update_tuned_intervals', for the purpose. Once the command is written to the kdamond state file, the tuned sampling and aggregation intervals will be updated to the corresponding sysfs interface. Signed-off-by: SeongJae Park <sj@xxxxxxxxxx> --- mm/damon/sysfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index f9bfe9ea0ae6..b1829ee67762 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1213,6 +1213,11 @@ enum damon_sysfs_cmd { * effective size quota of the scheme in bytes. */ DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS, + /* + * @DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS: Update the tuned monitoring + * intevals. + */ + DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS, /* * @NR_DAMON_SYSFS_CMDS: Total number of DAMON sysfs commands. */ @@ -1230,6 +1235,7 @@ static const char * const damon_sysfs_cmd_strs[] = { "update_schemes_tried_regions", "clear_schemes_tried_regions", "update_schemes_effective_quotas", + "update_tuned_intervals", }; /* @@ -1502,6 +1508,17 @@ static int damon_sysfs_upd_schemes_effective_quotas(void *data) return 0; } +static int damon_sysfs_upd_tuned_intervals(void *data) +{ + struct damon_sysfs_kdamond *kdamond = data; + struct damon_ctx *ctx = kdamond->damon_ctx; + + kdamond->contexts->contexts_arr[0]->attrs->intervals->sample_us = + ctx->attrs.sample_interval; + kdamond->contexts->contexts_arr[0]->attrs->intervals->aggr_us = + ctx->attrs.aggr_interval; + return 0; +} /* * damon_sysfs_cmd_request_callback() - DAMON callback for handling requests. @@ -1723,6 +1740,9 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd, return damon_sysfs_damon_call( damon_sysfs_upd_schemes_effective_quotas, kdamond); + case DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS: + return damon_sysfs_damon_call( + damon_sysfs_upd_tuned_intervals, kdamond); default: break; } -- 2.39.5