* [PATCH 1/4] mm/damon/paddr: skip non-LRU folios as a whole in pageout
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
@ 2026-11-24 15:30 ` SJ Park
2026-11-24 15:30 ` [PATCH 2/4] mm/damon/core: skip apply_probes() when no probes are installed SJ Park
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: SJ Park @ 2026-11-24 15:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: Aveline Noir, SJ Park, damon, linux-mm, Enze Li
From: Aveline Noir <jm5905938@gmail.com>
damon_pa_pageout() uses damon_get_folio(), which rejects folios that are
not on the LRU. For a large non-LRU folio such as a hugetlb folio, the
loop then looks up the same folio once per base page even though
pageout cannot reclaim it.
Use damon_get_monitor_folio() and skip any returned non-LRU folio as a
whole by advancing to its end. Do this before the filters, the
accounting and the last_applied check, so that adjacent regions within
the same non-LRU folio are not walked by base page either.
In an x86-64 KVM pageout microbenchmark, traversal time dropped by
about 99.7% for regions covering whole 2 MiB hugetlb folios. For
4 KiB regions within hugetlb folios, traversal took about 1 ns more
per region.
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: Enze Li <lienze@kylinos.cn>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v2
- v2: https://lore.kernel.org/20261118-fix-damon-hugetlb-pageout-20261117-v2-1-547a65a3206e@gmail.com
- Collect R-b: from Enze and SJ.
- Rebase to the latest mm-new.
Changes in v2:
- v1: https://lore.kernel.org/20261117-fix-damon-hugetlb-pageout-20261117-v1-1-054ef8760a92@gmail.com
- Drop the redundant hugetlb check and update the subject and
description as suggested by SJ.
mm/damon/paddr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 411e1d557ba3f..83bc173c30504 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -268,7 +268,9 @@ static unsigned long damon_pa_pageout(struct damon_region *r,
addr = damon_pa_phys_addr(r->ar.start, addr_unit);
while (addr < damon_pa_phys_addr(r->ar.end, addr_unit)) {
- folio = damon_get_folio(PHYS_PFN(addr));
+ folio = damon_get_monitor_folio(PHYS_PFN(addr));
+ if (folio && !folio_test_lru(folio))
+ goto put_folio;
if (damon_pa_invalid_damos_folio(folio, s)) {
addr += PAGE_SIZE;
continue;
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/4] mm/damon/core: skip apply_probes() when no probes are installed
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
2026-11-24 15:30 ` [PATCH 1/4] mm/damon/paddr: skip non-LRU folios as a whole in pageout SJ Park
@ 2026-11-24 15:30 ` SJ Park
2026-11-24 15:30 ` [PATCH 3/4] selftests/damon/damos_quota: skip the last sample when counting exceeds SJ Park
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: SJ Park @ 2026-11-24 15:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: Aveline Noir, SJ Park, damon, linux-mm
From: Aveline Noir <jm5905938@gmail.com>
While measuring vaddr monitoring overhead, I noticed that kdamond calls
apply_probes() every sampling interval even if no probes are installed.
The vaddr callback walks the page tables for each region's sample, and
paddr looks up a folio and takes a reference if it can. There are no
probe hits to count in either case.
Skip the callback when the probe list is empty. Ordinary access checks
still run, and installed probes with zero weight are still applied.
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261119-damon-skip-empty-probes-20261119-v1-1-ec3e81c1f26b@gmail.com
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
mm/damon/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 649a4ac968abf..74058af5567fe 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -4105,7 +4105,7 @@ static int kdamond_fn(void *data)
if (!access_check_disabled && ctx->ops.check_accesses)
max_merge_score = ctx->ops.check_accesses(ctx);
- if (ctx->ops.apply_probes) {
+ if (ctx->ops.apply_probes && !list_empty(&ctx->probes)) {
if (time_after_eq(ctx->passed_sample_intervals,
next_aggregation_sis) &&
access_check_disabled)
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] selftests/damon/damos_quota: skip the last sample when counting exceeds
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
2026-11-24 15:30 ` [PATCH 1/4] mm/damon/paddr: skip non-LRU folios as a whole in pageout SJ Park
2026-11-24 15:30 ` [PATCH 2/4] mm/damon/core: skip apply_probes() when no probes are installed SJ Park
@ 2026-11-24 15:30 ` SJ Park
2026-11-24 15:30 ` [PATCH 4/4] mm/damon/tests/core-kunit: add test for damon_call() SJ Park
2026-11-24 15:39 ` [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit sashiko-bot
4 siblings, 0 replies; 6+ messages in thread
From: SJ Park @ 2026-11-24 15:30 UTC (permalink / raw)
To: Andrew Morton
Cc: Aveline Noir, SJ Park, Shuah Khan, Shuah Khan, damon,
linux-kselftest, linux-mm
From: Aveline Noir <jm5905938@gmail.com>
damos_quota.py expects qt_exceeds to be increased for every sample whose
tried_bytes equals the quota. The kernel increases it only when the next
quota window starts, so the last full window may still be pending when
the workload exits. The test then fails with an expected count one
higher than the actual one, e.g., 15 < 16.
Do not count the last sample. Also drop the sorting of the samples, so
that the last one is the latest.
Cc: Shuah Khan <shuah@kernel.org>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261117-fix-damon-quota-selftest-20261117-v1-1-c65d687d3def@gmail.com
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
tools/testing/selftests/damon/damos_quota.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py
index 879115a499bf8..bdfd22f000795 100755
--- a/tools/testing/selftests/damon/damos_quota.py
+++ b/tools/testing/selftests/damon/damos_quota.py
@@ -53,15 +53,16 @@ def main():
wss_collected.append(scheme.tried_bytes)
nr_quota_exceeds = scheme.stats.qt_exceeds
- wss_collected.sort()
nr_expected_quota_exceeds = 0
- for wss in wss_collected:
+ for idx, wss in enumerate(wss_collected):
if wss > sz_quota:
print('quota is not kept: %s > %s' % (wss, sz_quota))
print('collected samples are as below')
print('\n'.join(['%d' % wss for wss in wss_collected]))
exit(1)
- if wss == sz_quota:
+ # qt_exceeds is updated when the next quota window starts, so skip
+ # the last sample, whose window may still be pending.
+ if wss == sz_quota and idx < len(wss_collected) - 1:
nr_expected_quota_exceeds += 1
if nr_quota_exceeds < nr_expected_quota_exceeds:
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] mm/damon/tests/core-kunit: add test for damon_call()
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
` (2 preceding siblings ...)
2026-11-24 15:30 ` [PATCH 3/4] selftests/damon/damos_quota: skip the last sample when counting exceeds SJ Park
@ 2026-11-24 15:30 ` SJ Park
2026-11-24 15:39 ` [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit sashiko-bot
4 siblings, 0 replies; 6+ messages in thread
From: SJ Park @ 2026-11-24 15:30 UTC (permalink / raw)
To: Andrew Morton
Cc: Sailesh Nandanavanam, Brendan Higgins, David Gow, SJ Park, damon,
kunit-dev, linux-kselftest, linux-mm, Aveline Noir
From: Sailesh Nandanavanam <saileshnandanavanam@gmail.com>
A newly allocated damon_ctx has call_controls_obsolete set, meaning no
kdamond is available to handle call requests. damon_call() should
return -ECANCELED in that case instead of queueing the request and
waiting forever. When call_controls_obsolete is unset and
damon_call_control->repeat is set, damon_call() should return 0
without waiting for kdamond. Add a kunit test for the two cases.
Signed-off-by: Sailesh Nandanavanam <saileshnandanavanam@gmail.com>
Tested-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: Aveline Noir <jm5905938@gmail.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v2
- v2: https://lore.kernel.org/20261118063755.37749-1-saileshnandanavanam@gmail.com
- Collect R-b: from SJ.
- Rebase to the latest mm-new.
Changes from v1
(https://lore.kernel.org/20261117172219.26725-1-saileshnandanavanam@gmail.com,
https://lore.kernel.org/20261117174834.29182-1-saileshnandanavanam@gmail.com)
- Merge the two tests into damon_test_call().
- Drop the list_empty()/call_controls.next expectations.
- Drop list_del() on the stack-allocated control.
- Post as a single patch.
mm/damon/tests/core-kunit.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index a27545602680a..4446574a35652 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -2724,6 +2724,27 @@ static void damos_test_sz_ops_filter_passed_last(struct kunit *test)
damon_destroy_ctx(c);
}
+static void damon_test_call(struct kunit *test)
+{
+ struct damon_ctx *ctx;
+ struct damon_call_control control = {};
+ int ret;
+
+ ctx = damon_new_ctx();
+ if (!ctx)
+ kunit_skip(test, "ctx alloc fail");
+
+ ret = damon_call(ctx, &control);
+ KUNIT_EXPECT_EQ(test, ret, -ECANCELED);
+
+ ctx->call_controls_obsolete = false;
+ control.repeat = true;
+ ret = damon_call(ctx, &control);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+
+ damon_destroy_ctx(ctx);
+}
+
static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damon_test_target),
KUNIT_CASE(damon_test_regions),
@@ -2771,6 +2792,7 @@ static struct kunit_case damon_test_cases[] = {
KUNIT_CASE(damos_test_esz_goal_temporal),
KUNIT_CASE(damon_test_last_region_quota_reset),
KUNIT_CASE(damos_test_sz_ops_filter_passed_last),
+ KUNIT_CASE(damon_test_call),
{},
};
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit
2026-11-24 15:30 [PATCH 0/4] mm/damon: improve efficiency (paddr, core), fix a selftest, add a kunit SJ Park
` (3 preceding siblings ...)
2026-11-24 15:30 ` [PATCH 4/4] mm/damon/tests/core-kunit: add test for damon_call() SJ Park
@ 2026-11-24 15:39 ` sashiko-bot
4 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-24 15:39 UTC (permalink / raw)
To: SJ Park; +Cc: damon
Sashiko has reviewed this 4-patch series and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124153021.90142-1-sj@kernel.org
^ permalink raw reply [flat|nested] 6+ messages in thread