* [PATCH 01/11] mm/damon/core: introduce [in]active memory ratio damos quota goal metric
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-13 15:27 ` [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
` (9 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
DAMOS_LRU_[DE]PRIO are DAMOS actions for making balance of active and
inactive memory size. There is no appropriate DAMOS quota auto-tuning
target metric for the use case. Add two new DAMOS quota goal metrics
for the purpose, namely DAMOS_QUOTA_[IN]ACTIVE_MEM_BP. Those will
represent the ratio of [in]active memory to total (inactive + active)
memory. Hence, users will be able to ask DAMON to, for example, "find
hot and cold memory, and move pages of those to active and inactive LRU
lists, adjusting the hot/cold thresholds aiming 50:50 active:inactive
memory ratio."
Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/linux/damon.h | 4 ++++
mm/damon/core.c | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 650e7ecfa32b..26fb8e90dff6 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -155,6 +155,8 @@ enum damos_action {
* @DAMOS_QUOTA_NODE_MEM_FREE_BP: MemFree ratio of a node.
* @DAMOS_QUOTA_NODE_MEMCG_USED_BP: MemUsed ratio of a node for a cgroup.
* @DAMOS_QUOTA_NODE_MEMCG_FREE_BP: MemFree ratio of a node for a cgroup.
+ * @DAMOS_QUOTA_ACTIVE_MEM_BP: Active to total LRU memory ratio.
+ * @DAMOS_QUOTA_INACTIVE_MEM_BP: Inactive to total LRU memory ratio.
* @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics.
*
* Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported.
@@ -166,6 +168,8 @@ enum damos_quota_goal_metric {
DAMOS_QUOTA_NODE_MEM_FREE_BP,
DAMOS_QUOTA_NODE_MEMCG_USED_BP,
DAMOS_QUOTA_NODE_MEMCG_FREE_BP,
+ DAMOS_QUOTA_ACTIVE_MEM_BP,
+ DAMOS_QUOTA_INACTIVE_MEM_BP,
NR_DAMOS_QUOTA_GOAL_METRICS,
};
diff --git a/mm/damon/core.c b/mm/damon/core.c
index abda850c28c0..d2ed75e521bd 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2132,6 +2132,23 @@ static unsigned long damos_get_node_memcg_used_bp(
}
#endif
+/*
+ * Returns LRU-active or inactive memory to total LRU memory size ratio.
+ */
+static unsigned int damos_get_in_active_mem_bp(bool active_ratio)
+{
+ unsigned long active, inactive, total;
+
+ /* This should align with /proc/meminfo output */
+ active = global_node_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON) +
+ global_node_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE);
+ inactive = global_node_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON) +
+ global_node_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE);
+ total = active + inactive;
+ if (active_ratio)
+ return active * 10000 / total;
+ return inactive * 10000 / total;
+}
static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal)
{
@@ -2154,6 +2171,11 @@ static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal)
case DAMOS_QUOTA_NODE_MEMCG_FREE_BP:
goal->current_value = damos_get_node_memcg_used_bp(goal);
break;
+ case DAMOS_QUOTA_ACTIVE_MEM_BP:
+ case DAMOS_QUOTA_INACTIVE_MEM_BP:
+ goal->current_value = damos_get_in_active_mem_bp(
+ goal->metric == DAMOS_QUOTA_ACTIVE_MEM_BP);
+ break;
default:
break;
}
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
2026-01-13 15:27 ` [PATCH 01/11] mm/damon/core: introduce [in]active memory ratio damos quota goal metric SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-14 2:57 ` wang lian
2026-01-14 2:57 ` wang lian
2026-01-13 15:27 ` [PATCH 03/11] Docs/mm/damon/design: document DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
` (8 subsequent siblings)
10 siblings, 2 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
Add support of DAMOS_QUOTA_[IN]ACTIVE_MEM_BP on DAMON sysfs interface.
Users can use [in]active_mem_bp keyword input to the target_metric sysfs
file to use the new DAMOS quota auto-tune target metrics.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 419d6e7ee945..2b05a6477188 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -1079,6 +1079,14 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = {
.metric = DAMOS_QUOTA_NODE_MEMCG_FREE_BP,
.name = "node_memcg_free_bp",
},
+ {
+ .metric = DAMOS_QUOTA_ACTIVE_MEM_BP,
+ .name = "active_mem_bp",
+ },
+ {
+ .metric = DAMOS_QUOTA_INACTIVE_MEM_BP,
+ .name = "inactive_mem_bp",
+ },
};
static ssize_t target_metric_show(struct kobject *kobj,
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
2026-01-13 15:27 ` [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
@ 2026-01-14 2:57 ` wang lian
2026-01-14 2:57 ` wang lian
1 sibling, 0 replies; 18+ messages in thread
From: wang lian @ 2026-01-14 2:57 UTC (permalink / raw)
To: sj; +Cc: akpm, damon, linux-kernel, linux-mm, wang lian
> Add support of DAMOS_QUOTA_[IN]ACTIVE_MEM_BP on DAMON sysfs interface.
> Users can use [in]active_mem_bp keyword input to the target_metric sysfs
> file to use the new DAMOS quota auto-tune target metrics.
> Signed-off-by: SeongJae Park <sj@kernel.org>
Hi SeongJae,
The sysfs interface updates look correct
Acked-by: wang lian <lianux.mm@gmail.com>
--
Best Regards,
wang lian
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
2026-01-13 15:27 ` [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
2026-01-14 2:57 ` wang lian
@ 2026-01-14 2:57 ` wang lian
1 sibling, 0 replies; 18+ messages in thread
From: wang lian @ 2026-01-14 2:57 UTC (permalink / raw)
To: sj; +Cc: akpm, damon, linux-kernel, linux-mm, wang lian
> Add support of DAMOS_QUOTA_[IN]ACTIVE_MEM_BP on DAMON sysfs interface.
> Users can use [in]active_mem_bp keyword input to the target_metric sysfs
> file to use the new DAMOS quota auto-tune target metrics.
> Signed-off-by: SeongJae Park <sj@kernel.org>
Hi SeongJae,
The sysfs interface updates look correct.
Acked-by: wang lian <lianux.mm@gmail.com>
--
Best Regards,
wang lian
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 03/11] Docs/mm/damon/design: document DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
2026-01-13 15:27 ` [PATCH 01/11] mm/damon/core: introduce [in]active memory ratio damos quota goal metric SeongJae Park
2026-01-13 15:27 ` [PATCH 02/11] mm/damon/sysfs-schemes: support DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-14 2:51 ` wang lian
2026-01-13 15:27 ` [PATCH 04/11] mm/damon/paddr: activate DAMOS_LRU_PRIO targets instead of marking accessed SeongJae Park
` (7 subsequent siblings)
10 siblings, 1 reply; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Liam R. Howlett, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Update design document for newly added DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
metrics. Note that API document is automatically updated by kernel-doc
comment, and the usage document points to the design document which uses
keywords same to that for sysfs inputs. Hence updating only design
document is sufficient.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index 7fd819b8bbf7..0cfd4c25e92d 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -585,6 +585,10 @@ mechanism tries to make ``current_value`` of ``target_metric`` be same to
specific NUMA node, in bp (1/10,000).
- ``node_memcg_free_bp``: Specific cgroup's node unused memory ratio for a
specific NUMA node, in bp (1/10,000).
+- ``active_mem_bp``: Active to active + inactive (LRU) memory size ratio in bp
+ (1/10,000).
+- ``inactive_mem_bp``: Inactive to active + inactive (LRU) memory size ratio in
+ bp (1/10,000).
``nid`` is optionally required for only ``node_mem_used_bp``,
``node_mem_free_bp``, ``node_memcg_used_bp`` and ``node_memcg_free_bp`` to
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 03/11] Docs/mm/damon/design: document DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
2026-01-13 15:27 ` [PATCH 03/11] Docs/mm/damon/design: document DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
@ 2026-01-14 2:51 ` wang lian
0 siblings, 0 replies; 18+ messages in thread
From: wang lian @ 2026-01-14 2:51 UTC (permalink / raw)
To: sj
Cc: Liam.Howlett, akpm, corbet, damon, david, linux-doc,
linux-kernel, linux-mm, lorenzo.stoakes, mhocko, rppt, surenb,
vbabka, wang lian
> Update design document for newly added DAMOS_QUOTA_[IN]ACTIVE_MEM_BP
> metrics. Note that API document is automatically updated by kernel-doc
> comment, and the usage document points to the design document which uses
> keywords same to that for sysfs inputs. Hence updating only design
> document is sufficient.
> Signed-off-by: SeongJae Park <sj@kernel.org>
Hi SeongJae,
The documentation clearly reflects the definition implemented in patch 1.
Acked-by: wang lian <lianux.mm@gmail.com>
--
Best Regards,
wang lian
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 04/11] mm/damon/paddr: activate DAMOS_LRU_PRIO targets instead of marking accessed
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (2 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 03/11] Docs/mm/damon/design: document DAMOS_QUOTA_[IN]ACTIVE_MEM_BP SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-13 15:27 ` [PATCH 05/11] mm/damon/lru_sort: consider age for quota prioritization SeongJae Park
` (6 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
DAMOS_LRU_DEPRIOD directly deactivates the pages, while DAMOS_LRU_PRIO
calls folio_mark_accessed(), which does incremental activation. The
incremental activation was assumed to be useful for making sure the
pages of the hot memory region are really hot. After the introduction
of DAMOS_LRU_PRIO, the young page filter has added. Users can use the
young page filter to make sure the page is eligible to be activated.
Meanwhile, the asymmetric behavior of DAMOS_LRU_[DE]PRIO can confuse
users.
Directly activate given pages for DAMOS_LRU_PRIO, to eliminate the
unnecessary incremental activation steps, and be symmetric with
DAMOS_LRU_DEPRIO for easier usages.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/paddr.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 7d887a3c0866..4c2c935d82d6 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -206,9 +206,9 @@ static unsigned long damon_pa_pageout(struct damon_region *r,
return damon_pa_core_addr(applied * PAGE_SIZE, addr_unit);
}
-static inline unsigned long damon_pa_mark_accessed_or_deactivate(
+static inline unsigned long damon_pa_de_activate(
struct damon_region *r, unsigned long addr_unit,
- struct damos *s, bool mark_accessed,
+ struct damos *s, bool activate,
unsigned long *sz_filter_passed)
{
phys_addr_t addr, applied = 0;
@@ -227,8 +227,8 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate(
else
*sz_filter_passed += folio_size(folio) / addr_unit;
- if (mark_accessed)
- folio_mark_accessed(folio);
+ if (activate)
+ folio_activate(folio);
else
folio_deactivate(folio);
applied += folio_nr_pages(folio);
@@ -240,20 +240,18 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate(
return damon_pa_core_addr(applied * PAGE_SIZE, addr_unit);
}
-static unsigned long damon_pa_mark_accessed(struct damon_region *r,
+static unsigned long damon_pa_activate_pages(struct damon_region *r,
unsigned long addr_unit, struct damos *s,
unsigned long *sz_filter_passed)
{
- return damon_pa_mark_accessed_or_deactivate(r, addr_unit, s, true,
- sz_filter_passed);
+ return damon_pa_de_activate(r, addr_unit, s, true, sz_filter_passed);
}
static unsigned long damon_pa_deactivate_pages(struct damon_region *r,
unsigned long addr_unit, struct damos *s,
unsigned long *sz_filter_passed)
{
- return damon_pa_mark_accessed_or_deactivate(r, addr_unit, s, false,
- sz_filter_passed);
+ return damon_pa_de_activate(r, addr_unit, s, false, sz_filter_passed);
}
static unsigned long damon_pa_migrate(struct damon_region *r,
@@ -327,7 +325,7 @@ static unsigned long damon_pa_apply_scheme(struct damon_ctx *ctx,
case DAMOS_PAGEOUT:
return damon_pa_pageout(r, aunit, scheme, sz_filter_passed);
case DAMOS_LRU_PRIO:
- return damon_pa_mark_accessed(r, aunit, scheme,
+ return damon_pa_activate_pages(r, aunit, scheme,
sz_filter_passed);
case DAMOS_LRU_DEPRIO:
return damon_pa_deactivate_pages(r, aunit, scheme,
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 05/11] mm/damon/lru_sort: consider age for quota prioritization
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (3 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 04/11] mm/damon/paddr: activate DAMOS_LRU_PRIO targets instead of marking accessed SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-13 15:27 ` [PATCH 06/11] mm/damon/lru_sort: support young page filters SeongJae Park
` (5 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
DAMON_LRU_SORT is doing under-quota access pattern based regions
prioritization using only access frequency. Age of regions is another
useful information for distinguishing hot and cold regions. Use it for
prioritization, too.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/lru_sort.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index 9388b091deb7..a74c4ec170a9 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -71,7 +71,7 @@ static struct damos_quota damon_lru_sort_quota = {
/* Within the quota, mark hotter regions accessed first. */
.weight_sz = 0,
.weight_nr_accesses = 1,
- .weight_age = 0,
+ .weight_age = 1,
};
DEFINE_DAMON_MODULES_DAMOS_TIME_QUOTA(damon_lru_sort_quota);
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 06/11] mm/damon/lru_sort: support young page filters
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (4 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 05/11] mm/damon/lru_sort: consider age for quota prioritization SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-13 15:27 ` [PATCH 07/11] Docs/admin-guide/mm/damon/lru_sort: document filter_young_pages SeongJae Park
` (4 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
DAMON monitors access patterns at the region level, and hence there
could be some page level mismatches. A few hot pages could be located
in cold regions, and vice versa. Young page filters can be useful for
doing additional page level access checks before applying some DAMOS
action.
DAMON_LRU_SORT is not using young page filters, though. Add a parameter
for using it.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/lru_sort.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index a74c4ec170a9..f1fdb37b9b47 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -41,6 +41,21 @@ static bool enabled __read_mostly;
static bool commit_inputs __read_mostly;
module_param(commit_inputs, bool, 0600);
+/*
+ * Filter [non-]young pages accordingly for LRU [de]prioritizations.
+ *
+ * If this is set, check page level access (youngness) once again before each
+ * LRU [de]prioritization operation. LRU prioritization operation is skipped
+ * if the page has not accessed since the last check (not young). LRU
+ * deprioritization operation is skipped if the page has accessed since the
+ * last check (young). The feature is enabled or disabled if this parameter is
+ * set as ``Y`` or ``N``, respectively.
+ *
+ * Disabled by default.
+ */
+static bool filter_young_pages __read_mostly;
+module_param(filter_young_pages, bool, 0600);
+
/*
* Access frequency threshold for hot memory regions identification in permil.
*
@@ -193,6 +208,28 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres)
return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO);
}
+static int damon_lru_sort_add_filters(struct damos *hot_scheme,
+ struct damos *cold_scheme)
+{
+ struct damos_filter *filter;
+
+ if (!filter_young_pages)
+ return 0;
+
+ /* disallow prioritizing not-young pages */
+ filter = damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, false, false);
+ if (!filter)
+ return -ENOMEM;
+ damos_add_filter(hot_scheme, filter);
+
+ /* disabllow de-prioritizing young pages */
+ filter = damos_new_filter(DAMOS_FILTER_TYPE_YOUNG, true, false);
+ if (!filter)
+ return -ENOMEM;
+ damos_add_filter(cold_scheme, filter);
+ return 0;
+}
+
static int damon_lru_sort_apply_parameters(void)
{
struct damon_ctx *param_ctx;
@@ -240,6 +277,10 @@ static int damon_lru_sort_apply_parameters(void)
damon_set_schemes(param_ctx, &hot_scheme, 1);
damon_add_scheme(param_ctx, cold_scheme);
+ err = damon_lru_sort_add_filters(hot_scheme, cold_scheme);
+ if (err)
+ goto out;
+
err = damon_set_region_biggest_system_ram_default(param_target,
&monitor_region_start,
&monitor_region_end,
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 07/11] Docs/admin-guide/mm/damon/lru_sort: document filter_young_pages
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (5 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 06/11] mm/damon/lru_sort: support young page filters SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-14 3:25 ` wang lian
2026-01-13 15:27 ` [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning SeongJae Park
` (3 subsequent siblings)
10 siblings, 1 reply; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Liam R. Howlett, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Document the new DAMON_LRU_SORT parameter, filter_young_pages. It can
be used to use page level access re-check for the LRU sorting.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/lru_sort.rst | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentation/admin-guide/mm/damon/lru_sort.rst
index 72a943202676..bb222a32aefd 100644
--- a/Documentation/admin-guide/mm/damon/lru_sort.rst
+++ b/Documentation/admin-guide/mm/damon/lru_sort.rst
@@ -79,6 +79,20 @@ of parametrs except ``enabled`` again. Once the re-reading is done, this
parameter is set as ``N``. If invalid parameters are found while the
re-reading, DAMON_LRU_SORT will be disabled.
+filter_young_pages
+------------------
+
+Filter [non-]young pages accordingly for LRU [de]prioritizations.
+
+If this is set, check page level access (youngness) once again before each
+LRU [de]prioritization operation. LRU prioritization operation is skipped
+if the page has not accessed since the last check (not young). LRU
+deprioritization operation is skipped if the page has accessed since the
+last check (young). The feature is enabled or disabled if this parameter is
+set as ``Y`` or ``N``, respectively.
+
+Disabled by default.
+
hot_thres_access_freq
---------------------
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 07/11] Docs/admin-guide/mm/damon/lru_sort: document filter_young_pages
2026-01-13 15:27 ` [PATCH 07/11] Docs/admin-guide/mm/damon/lru_sort: document filter_young_pages SeongJae Park
@ 2026-01-14 3:25 ` wang lian
0 siblings, 0 replies; 18+ messages in thread
From: wang lian @ 2026-01-14 3:25 UTC (permalink / raw)
To: sj
Cc: Liam.Howlett, akpm, corbet, damon, david, linux-doc,
linux-kernel, linux-mm, lorenzo.stoakes, mhocko, rppt, surenb,
vbabka, wang lian
> Document the new DAMON_LRU_SORT parameter, filter_young_pages. It can
> be used to use page level access re-check for the LRU sorting.
> Signed-off-by: SeongJae Park <sj@kernel.org>
Acked-by: wang lian <lianux.mm@gmail.com>
--
Best Regards,
wang lian
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (6 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 07/11] Docs/admin-guide/mm/damon/lru_sort: document filter_young_pages SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-14 5:36 ` wang lian
2026-01-13 15:27 ` [PATCH 09/11] Docs/admin-guide/mm/damon/lru_sort: document active_mem_bp parameter SeongJae Park
` (2 subsequent siblings)
10 siblings, 1 reply; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
Doing DAMOS_LRU_[DE]PRIO with DAMOS_QUOTA_[IN]ACTIVE_MEM_BP based quota
auto-tuning can be easy and intuitive, compared to the manual
[de]prioritization target access pattern thresholds tuning. For
example, users can ask DAMON to "find hot/cold pages and
activate/deactivate those aiming 50:50 active:inactive memory size." But
DAMON_LRU_SORT has no interface to do that. Add a module parameter for
setting the target ratio.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/lru_sort.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index f1fdb37b9b47..f3a9dfc246b6 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -41,6 +41,20 @@ static bool enabled __read_mostly;
static bool commit_inputs __read_mostly;
module_param(commit_inputs, bool, 0600);
+/*
+ * Desired active to [in]active memory ratio in bp (1/10,000).
+ *
+ * While keeping the caps that set by other quotas, DAMON_LRU_SORT
+ * automatically increases and decreases the effective level of the quota
+ * aiming the LRU [de]prioritizations of the hot and cold memory resulting in
+ * this active to [in]active memory ratio. Value zero means disabling this
+ * auto-tuning feature.
+ *
+ * Disabled by default.
+ */
+static unsigned long active_mem_bp __read_mostly;
+module_param(active_mem_bp, ulong, 0600);
+
/*
* Filter [non-]young pages accordingly for LRU [de]prioritizations.
*
@@ -208,6 +222,26 @@ static struct damos *damon_lru_sort_new_cold_scheme(unsigned int cold_thres)
return damon_lru_sort_new_scheme(&pattern, DAMOS_LRU_DEPRIO);
}
+static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme,
+ struct damos *cold_scheme)
+{
+ struct damos_quota_goal *goal;
+
+ if (!active_mem_bp)
+ return 0;
+ goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp);
+ if (!goal)
+ return -ENOMEM;
+ damos_add_quota_goal(&hot_scheme->quota, goal);
+ /* aim 0.2 % goal conflict, to keep little ping pong */
+ goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP,
+ 10000 - active_mem_bp + 2);
+ if (!goal)
+ return -ENOMEM;
+ damos_add_quota_goal(&hot_scheme->quota, goal);
+ return 0;
+}
+
static int damon_lru_sort_add_filters(struct damos *hot_scheme,
struct damos *cold_scheme)
{
@@ -277,6 +311,9 @@ static int damon_lru_sort_apply_parameters(void)
damon_set_schemes(param_ctx, &hot_scheme, 1);
damon_add_scheme(param_ctx, cold_scheme);
+ err = damon_lru_sort_add_quota_goals(hot_scheme, cold_scheme);
+ if (err)
+ goto out;
err = damon_lru_sort_add_filters(hot_scheme, cold_scheme);
if (err)
goto out;
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning
2026-01-13 15:27 ` [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning SeongJae Park
@ 2026-01-14 5:36 ` wang lian
2026-01-14 5:53 ` SeongJae Park
0 siblings, 1 reply; 18+ messages in thread
From: wang lian @ 2026-01-14 5:36 UTC (permalink / raw)
To: sj; +Cc: akpm, damon, linux-kernel, linux-mm, wang lian
> Doing DAMOS_LRU_[DE]PRIO with DAMOS_QUOTA_[IN]ACTIVE_MEM_BP based quota
> auto-tuning can be easy and intuitive, compared to the manual
> [de]prioritization target access pattern thresholds tuning. For
> example, users can ask DAMON to "find hot/cold pages and
> activate/deactivate those aiming 50:50 active:inactive memory size." But
> DAMON_LRU_SORT has no interface to do that. Add a module parameter for
> setting the target ratio.
> Signed-off-by: SeongJae Park <sj@kernel.org>
```
> +static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme,
> + struct damos *cold_scheme)
> +{
> struct damos_quota_goal *goal;
> +
> + if (!active_mem_bp)
> + return 0;
> + goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp);
> + if (!goal)
> + return -ENOMEM;
> + damos_add_quota_goal(&hot_scheme->quota, goal);
> + /* aim 0.2 % goal conflict, to keep little ping pong */
> + goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP,
> + 10000 - active_mem_bp + 2);
> + if (!goal)
> + return -ENOMEM;
> + damos_add_quota_goal(&hot_scheme->quota, goal);
> + return 0;
> +}
The second goal (Inactive ratio target) is added to hot_scheme again.
Should this be cold_scheme? Currently the cold_scheme parameter appears to be unused.
--
Best Regards,
wang lian
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning
2026-01-14 5:36 ` wang lian
@ 2026-01-14 5:53 ` SeongJae Park
0 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-14 5:53 UTC (permalink / raw)
To: wang lian; +Cc: SeongJae Park, akpm, damon, linux-kernel, linux-mm
On Wed, 14 Jan 2026 13:36:28 +0800 wang lian <lianux.mm@gmail.com> wrote:
>
> > Doing DAMOS_LRU_[DE]PRIO with DAMOS_QUOTA_[IN]ACTIVE_MEM_BP based quota
> > auto-tuning can be easy and intuitive, compared to the manual
> > [de]prioritization target access pattern thresholds tuning. For
> > example, users can ask DAMON to "find hot/cold pages and
> > activate/deactivate those aiming 50:50 active:inactive memory size." But
> > DAMON_LRU_SORT has no interface to do that. Add a module parameter for
> > setting the target ratio.
>
> > Signed-off-by: SeongJae Park <sj@kernel.org>
>
> ```
> > +static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme,
> > + struct damos *cold_scheme)
> > +{
> > struct damos_quota_goal *goal;
> > +
> > + if (!active_mem_bp)
> > + return 0;
> > + goal = damos_new_quota_goal(DAMOS_QUOTA_ACTIVE_MEM_BP, active_mem_bp);
> > + if (!goal)
> > + return -ENOMEM;
> > + damos_add_quota_goal(&hot_scheme->quota, goal);
> > + /* aim 0.2 % goal conflict, to keep little ping pong */
> > + goal = damos_new_quota_goal(DAMOS_QUOTA_INACTIVE_MEM_BP,
> > + 10000 - active_mem_bp + 2);
> > + if (!goal)
> > + return -ENOMEM;
> > + damos_add_quota_goal(&hot_scheme->quota, goal);
> > + return 0;
> > +}
>
> The second goal (Inactive ratio target) is added to hot_scheme again.
> Should this be cold_scheme? Currently the cold_scheme parameter appears to be unused.
You are right, thank you for catching this, Wang!
Andrew, could you please add below attaching fixup?
Thanks,
SJ
[...]
=== >8 ===
From c8dbbf0cfb01de606d47f455bccc2d7b2d6d07ef Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj@kernel.org>
Date: Tue, 13 Jan 2026 21:48:53 -0800
Subject: [PATCH] mm/damon/lru_sort: add inactive mem ratio quota goal to
cold_scheme
damon_lru_sort_add_quota_goals() is adding inactive memory ratio quota
goal, which is for cold pages scheme, to hot pages scheme. Fix it.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/lru_sort.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index f3a9dfc246b6..8af97642912a 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -238,7 +238,7 @@ static int damon_lru_sort_add_quota_goals(struct damos *hot_scheme,
10000 - active_mem_bp + 2);
if (!goal)
return -ENOMEM;
- damos_add_quota_goal(&hot_scheme->quota, goal);
+ damos_add_quota_goal(&cold_scheme->quota, goal);
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 09/11] Docs/admin-guide/mm/damon/lru_sort: document active_mem_bp parameter
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (7 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 08/11] mm/damon/lru_sort: support active:inactive memory ratio based auto-tuning SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-13 15:27 ` [PATCH 10/11] mm/damon/lru_sort: add monitoring intervals auto-tuning parameter SeongJae Park
2026-01-13 15:27 ` [PATCH 11/11] Docs/admin-guide/mm/damon/lru_sort: document intervals autotuning SeongJae Park
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Liam R. Howlett, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Document a newly added DAMON_LRU_SORT parameter for doing auto-tuning
aiming an active to inactive memory size ratio.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/lru_sort.rst | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentation/admin-guide/mm/damon/lru_sort.rst
index bb222a32aefd..6af3ab5579a3 100644
--- a/Documentation/admin-guide/mm/damon/lru_sort.rst
+++ b/Documentation/admin-guide/mm/damon/lru_sort.rst
@@ -79,6 +79,18 @@ of parametrs except ``enabled`` again. Once the re-reading is done, this
parameter is set as ``N``. If invalid parameters are found while the
re-reading, DAMON_LRU_SORT will be disabled.
+active_mem_bp
+-------------
+
+Desired active to [in]active memory ratio in bp (1/10,000).
+
+While keeping the caps that set by other quotas, DAMON_LRU_SORT automatically
+increases and decreases the effective level of the quota aiming the LRU
+[de]prioritizations of the hot and cold memory resulting in this active to
+[in]active memory ratio. Value zero means disabling this auto-tuning feature.
+
+Disabled by default.
+
filter_young_pages
------------------
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 10/11] mm/damon/lru_sort: add monitoring intervals auto-tuning parameter
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (8 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 09/11] Docs/admin-guide/mm/damon/lru_sort: document active_mem_bp parameter SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
2026-01-13 15:27 ` [PATCH 11/11] Docs/admin-guide/mm/damon/lru_sort: document intervals autotuning SeongJae Park
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: SeongJae Park, damon, linux-kernel, linux-mm
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.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/lru_sort.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index f3a9dfc246b6..717cc585d207 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -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);
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 11/11] Docs/admin-guide/mm/damon/lru_sort: document intervals autotuning
2026-01-13 15:27 [PATCH 00/11] mm/damon: advance DAMOS-based LRU sorting SeongJae Park
` (9 preceding siblings ...)
2026-01-13 15:27 ` [PATCH 10/11] mm/damon/lru_sort: add monitoring intervals auto-tuning parameter SeongJae Park
@ 2026-01-13 15:27 ` SeongJae Park
10 siblings, 0 replies; 18+ messages in thread
From: SeongJae Park @ 2026-01-13 15:27 UTC (permalink / raw)
To: Andrew Morton
Cc: SeongJae Park, Liam R. Howlett, David Hildenbrand,
Jonathan Corbet, Lorenzo Stoakes, Michal Hocko, Mike Rapoport,
Suren Baghdasaryan, Vlastimil Babka, damon, linux-doc,
linux-kernel, linux-mm
Document a newly added DAMON_LRU_SORT module parameter for using
monitoring intervals auto-tuning feature of DAMON.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/lru_sort.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/lru_sort.rst b/Documentation/admin-guide/mm/damon/lru_sort.rst
index 6af3ab5579a3..20a8378d5a94 100644
--- a/Documentation/admin-guide/mm/damon/lru_sort.rst
+++ b/Documentation/admin-guide/mm/damon/lru_sort.rst
@@ -91,6 +91,17 @@ increases and decreases the effective level of the quota aiming the LRU
Disabled by default.
+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.
+
filter_young_pages
------------------
--
2.47.3
^ permalink raw reply [flat|nested] 18+ messages in thread