* [PATCH RFC] mm/damon/core: preserve region age differences during merging
@ 2026-11-30 12:25 Aveline Noir
2026-11-30 13:08 ` sashiko-bot
0 siblings, 1 reply; 3+ messages in thread
From: Aveline Noir @ 2026-11-30 12:25 UTC (permalink / raw)
To: SJ Park, Andrew Morton; +Cc: damon, linux-mm, linux-kernel
DAMOS can split a region to fit the remaining quota and reset the age of
the part it acts on. If the two parts still have similar access
frequencies, a merge can bring the size-weighted age below the scheme's
minimum age and delay work on the untouched part.
On the first merge pass, keep adjacent regions separate if either has no
accesses and their ages differ by more than both ten aggregation
intervals and the younger region's age. Leave the retry passes free to
merge them when the region count exceeds the configured limit.
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
---
Hi all,
I'm not sure how this change would behave in production. I ran an
eight-range SQLite workload for 900 seconds per run with PADDR, a
120-second minimum age, and THP=never. Started with the default limit of
1000 regions. In three exploratory pairs with tracing enabled, the patch
saved 164 to 203 MiB, but SELECT throughput fell by 3.60% to 4.04%.
Including reclaim and tracing, kdamond used 32.88 to 42.54 ms more CPU
per monitoring second. Swap-ins increased by roughly 65,000 to 96,000
pages.
So I then tried lower limits. In this case, 300 regions looks like a
reasonable trade-off. In six fresh pairs with tracing disabled, the
median memory saving was 84.45 MiB (76.89 to 97.12 MiB). Median SELECT
throughput loss was 0.72% (0.28% to 1.03%). The median increase in
kdamond CPU time, including reclaim, was 10.64 ms per monitoring second
(8.18 to 11.94 ms/s). Swap-ins increased by a median of about 35,800
pages.
Those measurements used the same merge rule on a v7.4-rc2-based kernel.
All 56 DAMON KUnit tests passed with this patch on damon/for-next in
x86-64 QEMU. I may also experiment with different age difference
thresholds later.
I'd be interested to hear from you guys :)
GPT-6 Astra helped through these tests.
---
mm/damon/core.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index b791a2621bd6..70545b3e16ff 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3745,6 +3745,11 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
goto set_prev_continue;
if (damon_sz_region(prev) + damon_sz_region(r) > sz_limit)
goto set_prev_continue;
+ /* Preserve age differences for DAMOS on the first pass. */
+ if (count_age && (!r->nr_accesses || !prev->nr_accesses) &&
+ abs_diff(prev->age, r->age) >
+ max(10U, min(prev->age, r->age)))
+ goto set_prev_continue;
damon_merge_two_regions(ctx, t, prev, r);
continue;
set_prev_continue:
---
base-commit: cb30f5a374c534a3d12879d85f73599489172eb6
change-id: 20261130-damon-preserve-region-age-cb9a1a41bf83
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] mm/damon/core: preserve region age differences during merging
2026-11-30 12:25 [PATCH RFC] mm/damon/core: preserve region age differences during merging Aveline Noir
@ 2026-11-30 13:08 ` sashiko-bot
2026-11-30 13:24 ` Aveline Noir
0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-30 13:08 UTC (permalink / raw)
To: Aveline Noir, SJ Park, Andrew Morton; +Cc: damon, linux-mm
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/damon/core: raw nr_accesses check in
damon_merge_regions_of()
--
commit 31ad98d8e8cfd0d1ff1566fceab291b4a0aa0418
Author: Aveline Noir <jm5905938@gmail.com>
mm/damon/core: preserve region age differences during merging
This commit skips merging adjacent regions on the first merge pass in
damon_merge_regions_of() if either region has no accesses and their age
difference exceeds both 10 aggregation intervals and the younger region's
age.
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index b791a2621bd62..70545b3e16ff3 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3745,6 +3745,11 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
> goto set_prev_continue;
> if (damon_sz_region(prev) + damon_sz_region(r) > sz_limit)
> goto set_prev_continue;
> + /* Preserve age differences for DAMOS on the first pass. */
> + if (count_age && (!r->nr_accesses || !prev->nr_accesses) &&
> + abs_diff(prev->age, r->age) >
> + max(10U, min(prev->age, r->age)))
> + goto set_prev_continue;
[Severity: Medium]
Should this check score and damon_merge_score(prev, false, ctx,
use_probe_hits) instead of r->nr_accesses and prev->nr_accesses?
When damon_has_probe_weights(ctx) is true, kdamond_fn() skips
ctx->ops.check_accesses(ctx) and leaves nr_accesses at 0 for all regions.
As a result, (!r->nr_accesses || !prev->nr_accesses) is always true when
probe weights are configured, preventing adjacent actively accessed
regions with non-zero probe-hit scores from merging whenever their ages
differ.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-damon-preserve-region-age-v1-1-8701093ad356@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] mm/damon/core: preserve region age differences during merging
2026-11-30 13:08 ` sashiko-bot
@ 2026-11-30 13:24 ` Aveline Noir
0 siblings, 0 replies; 3+ messages in thread
From: Aveline Noir @ 2026-11-30 13:24 UTC (permalink / raw)
To: sashiko-reviews, sj, akpm; +Cc: damon, linux-mm
On Mon, Nov 30, 2026 at 01:08:37PM +0000, sashiko-bot@kernel.org wrote:
> Should this check score and damon_merge_score(prev, false, ctx,
> use_probe_hits) instead of r->nr_accesses and prev->nr_accesses?
Makes sense. I'll address this in the next revision.
Thanks,
Aveline
On Mon, 30 Nov 2026 13:08:37 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] mm/damon/core: raw nr_accesses check in
> damon_merge_regions_of()
> --
>
> commit 31ad98d8e8cfd0d1ff1566fceab291b4a0aa0418
> Author: Aveline Noir <jm5905938@gmail.com>
>
> mm/damon/core: preserve region age differences during merging
>
> This commit skips merging adjacent regions on the first merge pass in
> damon_merge_regions_of() if either region has no accesses and their age
> difference exceeds both 10 aggregation intervals and the younger region's
> age.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index b791a2621bd62..70545b3e16ff3 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> > @@ -3745,6 +3745,11 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
> > goto set_prev_continue;
> > if (damon_sz_region(prev) + damon_sz_region(r) > sz_limit)
> > goto set_prev_continue;
> > + /* Preserve age differences for DAMOS on the first pass. */
> > + if (count_age && (!r->nr_accesses || !prev->nr_accesses) &&
> > + abs_diff(prev->age, r->age) >
> > + max(10U, min(prev->age, r->age)))
> > + goto set_prev_continue;
>
> [Severity: Medium]
> Should this check score and damon_merge_score(prev, false, ctx,
> use_probe_hits) instead of r->nr_accesses and prev->nr_accesses?
>
> When damon_has_probe_weights(ctx) is true, kdamond_fn() skips
> ctx->ops.check_accesses(ctx) and leaves nr_accesses at 0 for all regions.
> As a result, (!r->nr_accesses || !prev->nr_accesses) is always true when
> probe weights are configured, preventing adjacent actively accessed
> regions with non-zero probe-hit scores from merging whenever their ages
> differ.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261130-damon-preserve-region-age-v1-1-8701093ad356@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 13:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 12:25 [PATCH RFC] mm/damon/core: preserve region age differences during merging Aveline Noir
2026-11-30 13:08 ` sashiko-bot
2026-11-30 13:24 ` Aveline Noir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox