]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/damon/sysfs: implement a command to update auto-tuned monitoring intervals
authorSeongJae Park <sj@kernel.org>
Mon, 3 Mar 2025 22:17:23 +0000 (14:17 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 4 Mar 2025 05:50:40 +0000 (21:50 -0800)
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
command, namely 'update_tuned_intervals', for the purpose.  If the command
is written to the kdamond state file, the tuned sampling and aggregation
intervals will be updated to the corresponding sysfs interface files.

Link: https://lkml.kernel.org/r/20250303221726.484227-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs.c

index fa5f004f0670251d40011871e6b1d35097b66022..ccd435d234b97b81bffa48c07c7500af2b6ceb3e 100644 (file)
@@ -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;
        }