* [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms
@ 2026-12-03 15:32 SJ Park
2026-12-03 15:32 ` [PATCH 1/2] selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() SJ Park
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: SJ Park @ 2026-12-03 15:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: SJ Park, Shuah Khan, damon, linux-kselftest, linux-mm
Cleanup sysfs_memcg_path_leak to consistently use check_dependencies()
helper, via patch 1. Fixup DAMON_RECLAIM age_ms parameter to use age_ms
DAMOS filter to properly work in the intervals auto-tuning mode.
This is a batched reposting of separately posted and reviewed patches
for being merged into the mm.git. Refer to changelog on each patch for
changes that were made before this reposting.
Arijit Desai (1):
mm/damon/reclaim: use age_ms filter for min_age
Enze Li (1):
selftests/damon/sysfs_memcg_path_leak: use common check_dependencies()
mm/damon/reclaim.c | 18 ++++++++++++++----
.../selftests/damon/sysfs_memcg_path_leak.sh | 8 +++-----
2 files changed, 17 insertions(+), 9 deletions(-)
base-commit: 1a7610248a3802e38124ce66b07eef12277be9a0
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() 2026-12-03 15:32 [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms SJ Park @ 2026-12-03 15:32 ` SJ Park 2026-12-03 18:31 ` + selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies.patch added to mm-new branch Andrew Morton 2026-12-03 15:32 ` [PATCH 2/2] mm/damon/reclaim: use age_ms filter for min_age SJ Park 2026-12-03 15:52 ` [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms sashiko-bot 2 siblings, 1 reply; 6+ messages in thread From: SJ Park @ 2026-12-03 15:32 UTC (permalink / raw) To: Andrew Morton Cc: Enze Li, SJ Park, Shuah Khan, damon, linux-kselftest, linux-mm From: Enze Li <lienze@kylinos.cn> The sysfs_memcg_path_leak test is the only DAMON selftest shell script that does not source _common.sh. Instead it open-codes the root permission check that check_dependencies() already provides. Source _common.sh and call check_dependencies() to drop the duplicate. Signed-off-by: Enze Li <lienze@kylinos.cn> Reviewed-by: SJ Park <sj@kernel.org> Signed-off-by: SJ Park <sj@kernel.org> --- Changes from v1 - v1: https://lore.kernel.org/20261129020003.45921-1-enze.li@linux.dev - Collect R-b: from SJ. - Rebase to the lates mm-new. tools/testing/selftests/damon/sysfs_memcg_path_leak.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh b/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh index d407dddb879e..23e4940d7843 100755 --- a/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh +++ b/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh @@ -1,14 +1,12 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +source _common.sh + # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 -if [ $EUID -ne 0 ] -then - echo "Run as root" - exit $ksft_skip -fi +check_dependencies damon_sysfs="/sys/kernel/mm/damon/admin" if [ ! -d "$damon_sysfs" ] -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* + selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies.patch added to mm-new branch 2026-12-03 15:32 ` [PATCH 1/2] selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() SJ Park @ 2026-12-03 18:31 ` Andrew Morton 0 siblings, 0 replies; 6+ messages in thread From: Andrew Morton @ 2026-12-03 18:31 UTC (permalink / raw) To: mm-commits, sj, shuah, arijit.desai, lienze, akpm The patch titled Subject: selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() has been added to the -mm mm-new branch. Its filename is selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Enze Li <lienze@kylinos.cn> Subject: selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() Date: Thu, 03 Dec 2026 07:32:13 -0800 Patch series "mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms". Cleanup sysfs_memcg_path_leak to consistently use check_dependencies() helper, via patch 1. Fixup DAMON_RECLAIM age_ms parameter to use age_ms DAMOS filter to properly work in the intervals auto-tuning mode. This is a batched reposting of separately posted and reviewed patches for being merged into the mm.git. Refer to changelog on each patch for changes that were made before this reposting. This patch (of 2): The sysfs_memcg_path_leak test is the only DAMON selftest shell script that does not source _common.sh. Instead it open-codes the root permission check that check_dependencies() already provides. Source _common.sh and call check_dependencies() to drop the duplicate. Link: https://lore.kernel.org/20261203153215.733163-1-sj@kernel.org Link: https://patch.msgid.link/20261203153215.733163-2-sj@kernel.org Signed-off-by: Enze Li <lienze@kylinos.cn> Signed-off-by: SJ Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: SJ Park <sj@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: Arijit Desai <arijit.desai@crusoe.ai> tools/testing/selftests/damon/sysfs_memcg_path_leak.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh~selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies +++ a/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh @@ -1,14 +1,12 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +source _common.sh + # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 -if [ $EUID -ne 0 ] -then - echo "Run as root" - exit $ksft_skip -fi +check_dependencies damon_sysfs="/sys/kernel/mm/damon/admin" if [ ! -d "$damon_sysfs" ] _ Patches currently in -mm which might be from lienze@kylinos.cn are docs-hugetlbpagerst-clarify-hugepages_total-in-hugetlbpagerst.patch mm-hugetlb-drop-unused-mm-parameter-from-unmap_ref_private.patch mm-hugetlb_cma-remove-two-unused-include-files.patch mm-damon-core-use-list_nextprev_entry-in-damon_nextprev_region.patch docs-mm-damon-design-replace-same-to-with-same-as.patch selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies.patch ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] mm/damon/reclaim: use age_ms filter for min_age 2026-12-03 15:32 [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms SJ Park 2026-12-03 15:32 ` [PATCH 1/2] selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() SJ Park @ 2026-12-03 15:32 ` SJ Park 2026-12-03 18:31 ` + mm-damon-reclaim-use-age_ms-filter-for-min_age.patch added to mm-new branch Andrew Morton 2026-12-03 15:52 ` [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms sashiko-bot 2 siblings, 1 reply; 6+ messages in thread From: SJ Park @ 2026-12-03 15:32 UTC (permalink / raw) To: Andrew Morton; +Cc: Arijit Desai, SJ Park, damon, linux-mm From: Arijit Desai <arijit.desai@crusoe.ai> DAMON_RECLAIM converts its min_age parameter (in microseconds) into DAMOS min_age_region, which is in aggregation intervals, once when the parameters are applied. When autotune_monitoring_intervals is enabled, the conversion uses the initial 100 ms aggregation interval, but the auto-tuning soon grows the interval. The region age threshold therefore stays at the same number of aggregation intervals while each interval becomes much longer. For the default min_age of 120 seconds, the threshold becomes 1,200 aggregation intervals, which is about 2.5 hours once the aggregation interval grows to about 7.5 seconds. As a result, DAMON_RECLAIM reclaims almost nothing [1] in that setup. Use a DAMOS_FILTER_TYPE_AGE_MS filter that rejects regions younger than min_age instead, and set min_age_region to zero. The filter compares the region age converted with the current aggregation interval, so it stays correct while the intervals change. For fixed intervals, the behavior is unchanged. Regions rejected by the filter are not charged to the quota and do not count as tried regions. Keep accepting any min_age, as before. If min_age is smaller than a millisecond, add no filter, so every region is old enough. Tested on a 16 vCPU / 62 GiB VM with a cold anonymous buffer plus 1 GiB of hot anonymous memory, autotune_monitoring_intervals=Y, min_age=120 s and watermarks forced active: kernel cold buffer 10 min result unpatched 8 GiB no region tried, nothing paged out unpatched 48 GiB no region tried, nothing paged out patched 48 GiB nothing paged out before 181 s, then steady pageout (~1 GiB swapped out by 600 s, limited by the time quota) The same age_ms filter based min_age was also tested with a DAMOS pageout scheme set up via the DAMON sysfs interface, on a vLLM CPU inference workload (3B model, 32 concurrent users, intervals auto-tuning, min_age 120 s, 4 runs per setup). Compared to no DAMON, it reduced the vLLM worker's resident memory by about 1.8 GiB (of 18.4 GiB), at a cost of 0.2% output throughput and 0.3% inter-token latency. With the classic LRU instead of MGLRU, it reduced 1.55 GiB at 0.1% throughput and 0.1% latency cost. The same scheme with min_age converted to aggregation intervals once, as DAMON_RECLAIM does now, reduced only 0.06 GiB. [1] https://lore.kernel.org/20261121015324.83753-1-sj@kernel.org Signed-off-by: Arijit Desai <arijit.desai@crusoe.ai> Reviewed-by: SJ Park <sj@kernel.org> Signed-off-by: SJ Park <sj@kernel.org> --- Changes from v1 - v1: https://lore.kernel.org/20261130-damon-reclaim-age-ms-v1-1-595659163211@crusoe.ai - Add a context to the initial issue sharing link. - Drop verbose comment. - Collect R-b: from SJ. - Rebase to the latet mm-new. mm/damon/reclaim.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index a84cea070ec7..cb259391cd49 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -164,7 +164,7 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_reclaim_stat, static struct damon_ctx *ctx; static struct damon_target *target; -static struct damos *damon_reclaim_new_scheme(unsigned long aggr_interval) +static struct damos *damon_reclaim_new_scheme(void) { struct damos_access_pattern pattern = { /* Find regions having PAGE_SIZE or larger size */ @@ -173,8 +173,8 @@ static struct damos *damon_reclaim_new_scheme(unsigned long aggr_interval) /* and not accessed at all */ .min_nr_accesses = 0, .max_nr_accesses = 0, - /* for min_age or more micro-seconds */ - .min_age_region = min_age / aggr_interval, + /* min_age is applied via a DAMOS_FILTER_TYPE_AGE_MS filter */ + .min_age_region = 0, .max_age_region = UINT_MAX, }; @@ -227,7 +227,7 @@ static int damon_reclaim_apply_parameters(void) goto out; err = -ENOMEM; - scheme = damon_reclaim_new_scheme(attrs.aggr_interval); + scheme = damon_reclaim_new_scheme(); if (!scheme) goto out; damon_set_schemes(param_ctx, &scheme, 1); @@ -249,6 +249,16 @@ static int damon_reclaim_apply_parameters(void) damos_add_quota_goal(&scheme->quota, goal); } + if (min_age >= USEC_PER_MSEC) { + filter = damos_new_filter(DAMOS_FILTER_TYPE_AGE_MS, true, + false); + if (!filter) + goto out; + filter->range_min = 0; + filter->range_max = min_age / USEC_PER_MSEC - 1; + damos_add_filter(scheme, filter); + } + if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); if (!filter) -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* + mm-damon-reclaim-use-age_ms-filter-for-min_age.patch added to mm-new branch 2026-12-03 15:32 ` [PATCH 2/2] mm/damon/reclaim: use age_ms filter for min_age SJ Park @ 2026-12-03 18:31 ` Andrew Morton 0 siblings, 0 replies; 6+ messages in thread From: Andrew Morton @ 2026-12-03 18:31 UTC (permalink / raw) To: mm-commits, sj, lienze, arijit.desai, akpm The patch titled Subject: mm/damon/reclaim: use age_ms filter for min_age has been added to the -mm mm-new branch. Its filename is mm-damon-reclaim-use-age_ms-filter-for-min_age.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-reclaim-use-age_ms-filter-for-min_age.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Arijit Desai <arijit.desai@crusoe.ai> Subject: mm/damon/reclaim: use age_ms filter for min_age Date: Thu, 03 Dec 2026 07:32:14 -0800 DAMON_RECLAIM converts its min_age parameter (in microseconds) into DAMOS min_age_region, which is in aggregation intervals, once when the parameters are applied. When autotune_monitoring_intervals is enabled, the conversion uses the initial 100 ms aggregation interval, but the auto-tuning soon grows the interval. The region age threshold therefore stays at the same number of aggregation intervals while each interval becomes much longer. For the default min_age of 120 seconds, the threshold becomes 1,200 aggregation intervals, which is about 2.5 hours once the aggregation interval grows to about 7.5 seconds. As a result, DAMON_RECLAIM reclaims almost nothing [1] in that setup. Use a DAMOS_FILTER_TYPE_AGE_MS filter that rejects regions younger than min_age instead, and set min_age_region to zero. The filter compares the region age converted with the current aggregation interval, so it stays correct while the intervals change. For fixed intervals, the behavior is unchanged. Regions rejected by the filter are not charged to the quota and do not count as tried regions. Keep accepting any min_age, as before. If min_age is smaller than a millisecond, add no filter, so every region is old enough. Tested on a 16 vCPU / 62 GiB VM with a cold anonymous buffer plus 1 GiB of hot anonymous memory, autotune_monitoring_intervals=Y, min_age=120 s and watermarks forced active: kernel cold buffer 10 min result unpatched 8 GiB no region tried, nothing paged out unpatched 48 GiB no region tried, nothing paged out patched 48 GiB nothing paged out before 181 s, then steady pageout (~1 GiB swapped out by 600 s, limited by the time quota) The same age_ms filter based min_age was also tested with a DAMOS pageout scheme set up via the DAMON sysfs interface, on a vLLM CPU inference workload (3B model, 32 concurrent users, intervals auto-tuning, min_age 120 s, 4 runs per setup). Compared to no DAMON, it reduced the vLLM worker's resident memory by about 1.8 GiB (of 18.4 GiB), at a cost of 0.2% output throughput and 0.3% inter-token latency. With the classic LRU instead of MGLRU, it reduced 1.55 GiB at 0.1% throughput and 0.1% latency cost. The same scheme with min_age converted to aggregation intervals once, as DAMON_RECLAIM does now, reduced only 0.06 GiB. Link: https://patch.msgid.link/20261203153215.733163-3-sj@kernel.org Link: https://lore.kernel.org/20261121015324.83753-1-sj@kernel.org [1] Signed-off-by: Arijit Desai <arijit.desai@crusoe.ai> Signed-off-by: SJ Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: SJ Park <sj@kernel.org> Cc: Enze Li <lienze@kylinos.cn> mm/damon/reclaim.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/mm/damon/reclaim.c~mm-damon-reclaim-use-age_ms-filter-for-min_age +++ a/mm/damon/reclaim.c @@ -164,7 +164,7 @@ DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS( static struct damon_ctx *ctx; static struct damon_target *target; -static struct damos *damon_reclaim_new_scheme(unsigned long aggr_interval) +static struct damos *damon_reclaim_new_scheme(void) { struct damos_access_pattern pattern = { /* Find regions having PAGE_SIZE or larger size */ @@ -173,8 +173,8 @@ static struct damos *damon_reclaim_new_s /* and not accessed at all */ .min_nr_accesses = 0, .max_nr_accesses = 0, - /* for min_age or more micro-seconds */ - .min_age_region = min_age / aggr_interval, + /* min_age is applied via a DAMOS_FILTER_TYPE_AGE_MS filter */ + .min_age_region = 0, .max_age_region = UINT_MAX, }; @@ -227,7 +227,7 @@ static int damon_reclaim_apply_parameter goto out; err = -ENOMEM; - scheme = damon_reclaim_new_scheme(attrs.aggr_interval); + scheme = damon_reclaim_new_scheme(); if (!scheme) goto out; damon_set_schemes(param_ctx, &scheme, 1); @@ -249,6 +249,16 @@ static int damon_reclaim_apply_parameter damos_add_quota_goal(&scheme->quota, goal); } + if (min_age >= USEC_PER_MSEC) { + filter = damos_new_filter(DAMOS_FILTER_TYPE_AGE_MS, true, + false); + if (!filter) + goto out; + filter->range_min = 0; + filter->range_max = min_age / USEC_PER_MSEC - 1; + damos_add_filter(scheme, filter); + } + if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true, false); if (!filter) _ Patches currently in -mm which might be from arijit.desai@crusoe.ai are mm-damon-reclaim-use-age_ms-filter-for-min_age.patch ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms 2026-12-03 15:32 [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms SJ Park 2026-12-03 15:32 ` [PATCH 1/2] selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() SJ Park 2026-12-03 15:32 ` [PATCH 2/2] mm/damon/reclaim: use age_ms filter for min_age SJ Park @ 2026-12-03 15:52 ` sashiko-bot 2 siblings, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-12-03 15:52 UTC (permalink / raw) To: SJ Park; +Cc: damon Sashiko has reviewed this 2-patch series and found no issues. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261203153215.733163-1-sj@kernel.org ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-03 18:31 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-03 15:32 [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms SJ Park 2026-12-03 15:32 ` [PATCH 1/2] selftests/damon/sysfs_memcg_path_leak: use common check_dependencies() SJ Park 2026-12-03 18:31 ` + selftests-damon-sysfs_memcg_path_leak-use-common-check_dependencies.patch added to mm-new branch Andrew Morton 2026-12-03 15:32 ` [PATCH 2/2] mm/damon/reclaim: use age_ms filter for min_age SJ Park 2026-12-03 18:31 ` + mm-damon-reclaim-use-age_ms-filter-for-min_age.patch added to mm-new branch Andrew Morton 2026-12-03 15:52 ` [PATCH 0/2] mm/damon: cleanup memcg_path_leak selftest and fix DAMON_RECLAIM age_ms sashiko-bot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.