]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/damon/lru_sort: add monitoring intervals auto-tuning parameter
authorSeongJae Park <sj@kernel.org>
Tue, 13 Jan 2026 15:27:15 +0000 (07:27 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 27 Jan 2026 04:02:31 +0000 (20:02 -0800)
DAMON monitoring intervals tuning was crucial for every DAMON use case.
Now there are a tuning guideline and an automated intervals tuning
feature.  DAMON_LRU_SORT is still using manual control of intervals.  Add
a module parameter for utilizing the auto-tuning feature with a suggested
auto-tuning parameters.

Link: https://lkml.kernel.org/r/20260113152717.70459-11-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Acked-by: wang lian <lianux.mm@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/lru_sort.c

index 8af97642912a5d869300a43b44bc8d954bee1bcf..8296f984b428087e02cdbf58a6726ee9153b4449 100644 (file)
@@ -55,6 +55,20 @@ module_param(commit_inputs, bool, 0600);
 static unsigned long active_mem_bp __read_mostly;
 module_param(active_mem_bp, ulong, 0600);
 
+/*
+ * Auto-tune monitoring intervals.
+ *
+ * If this parameter is set as ``Y``, DAMON_LRU_SORT automatically tunes
+ * DAMON's sampling and aggregation intervals.  The auto-tuning aims to capture
+ * meaningful amount of access events in each DAMON-snapshot, while keeping the
+ * sampling interval 5 milliseconds in minimum, and 10 seconds in maximum.
+ * Setting this as ``N`` disables the auto-tuning.
+ *
+ * Disabled by default.
+ */
+static bool autotune_monitoring_intervals __read_mostly;
+module_param(autotune_monitoring_intervals, bool, 0600);
+
 /*
  * Filter [non-]young pages accordingly for LRU [de]prioritizations.
  *
@@ -268,6 +282,7 @@ static int damon_lru_sort_apply_parameters(void)
 {
        struct damon_ctx *param_ctx;
        struct damon_target *param_target;
+       struct damon_attrs attrs;
        struct damos *hot_scheme, *cold_scheme;
        unsigned int hot_thres, cold_thres;
        int err;
@@ -290,18 +305,27 @@ static int damon_lru_sort_apply_parameters(void)
                goto out;
        }
 
-       err = damon_set_attrs(param_ctx, &damon_lru_sort_mon_attrs);
+       attrs = damon_lru_sort_mon_attrs;
+       if (autotune_monitoring_intervals) {
+               attrs.sample_interval = 5000;
+               attrs.aggr_interval = 100000;
+               attrs.intervals_goal.access_bp = 40;
+               attrs.intervals_goal.aggrs = 3;
+               attrs.intervals_goal.min_sample_us = 5000;
+               attrs.intervals_goal.max_sample_us = 10 * 1000 * 1000;
+       }
+       err = damon_set_attrs(param_ctx, &attrs);
        if (err)
                goto out;
 
        err = -ENOMEM;
-       hot_thres = damon_max_nr_accesses(&damon_lru_sort_mon_attrs) *
+       hot_thres = damon_max_nr_accesses(&attrs) *
                hot_thres_access_freq / 1000;
        hot_scheme = damon_lru_sort_new_hot_scheme(hot_thres);
        if (!hot_scheme)
                goto out;
 
-       cold_thres = cold_min_age / damon_lru_sort_mon_attrs.aggr_interval;
+       cold_thres = cold_min_age / attrs.aggr_interval;
        cold_scheme = damon_lru_sort_new_cold_scheme(cold_thres);
        if (!cold_scheme) {
                damon_destroy_scheme(hot_scheme);