summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2026-01-13 18:27:15 +0300
committerAndrew Morton <akpm@linux-foundation.org>2026-01-27 07:02:31 +0300
commit4bdd692291275eaaabe993e1c4a7b5b01cd6dc37 (patch)
tree4a8f47a734bcf52d83e3dcb30aec63ad7f4e10d7
parentcdfca22d15ca5f0f6b3ff33a23e1672dccc74eda (diff)
downloadlinux-4bdd692291275eaaabe993e1c4a7b5b01cd6dc37.tar.xz
mm/damon/lru_sort: add monitoring intervals auto-tuning parameter
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>
-rw-r--r--mm/damon/lru_sort.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index 8af97642912a..8296f984b428 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -56,6 +56,20 @@ 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.
*
* If this is set, check page level access (youngness) once again before each
@@ -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);