From: SeongJae Park <sj@kernel.org>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: SeongJae Park <sj@kernel.org>,
damon@lists.linux.dev, Andrew Morton <akpm@linux-foundation.org>,
Shu Anzai <shu17az@gmail.com>,
Jiayuan Chen <jiayuan.chen@shopee.com>,
Quanmin Yan <yanquanmin1@huawei.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] mm/damon/core: detect internal variation above max_nr_regions/2
Date: Thu, 21 May 2026 07:30:48 -0700 [thread overview]
Message-ID: <20260521143049.82745-1-sj@kernel.org> (raw)
In-Reply-To: <20260521045236.115749-1-jiayuan.chen@linux.dev>
Hello Jiayuan,
On Thu, 21 May 2026 12:52:22 +0800 Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> kdamond_split_regions() bails out early when nr_regions is already
> above max_nr_regions / 2. A large region that picks up new internal
> variation after that point never gets split, so we lose visibility
> into its hot/cold structure.
>
> We hit this with damon-paddr on hugepage workloads and damon-vaddr
> on processes that mmap a large anonymous range.
>
> On our production tree we added a current_nr_regions counter (no
> good upstream home for it yet, so it's not in this series). We saw
> nr_regions never getting close to max_nr_regions, and the picture of
> the access pattern was too coarse.
Is 'current_nr_regions' somewhat showing the number of DAMON regions? If so,
you could also get the information from nr_regions field of damon_aggregated
tracepoint. I'm wondering if you considered using that but found a problem
that made you have to implement the internal change.
I will be happy to help removing such downstream changes.
>
> Example with max_nr_regions == 1500. A target ends up with 799
> small hot/cold regions plus one big region (an earlier merge
> collapsed a uniformly-accessed range into a single piece):
>
> H:hot
> C:cold
>
> r1 r2 r3 r800
> HHHHHH|CCCCCC|HHHHHH|...|HHHHHH..........................|
>
> nr_regions = 800 > max_nr_regions / 2 = 750
>
> Now a cold subarea shows up inside r800:
>
> r1 r2 r3 r800
> HHHHHH|CCCCCC|HHHHHH|...|HHHHHH........CCCCCC.............|
>
> The small regions can't merge with each other (their access counts
> differ), so budget never frees up. r800 can't be split because
> nr_regions > max_nr_regions / 2 returns early. The cold subarea
> stays invisible.
I agree this corner case could theoretically happen. But, would the small
regions have the current pattern forever? On real world systems having dynamic
access pattern, I guess those small regions may not keep the shape forever, and
give chance for the large region to be split. Am I missing something?
My theory also implies that this kind of situation could happen at least
sometimes for temporal periods. In other words, it could happens too
frequently and too long to be problematic. But, in the case, maybe the user
could mitigate the issue by increasing the max_nr_regions. I'm curious if you
considered that direction and found a problem that I don't expect for now.
>
> Patch 1 lets this path still split regions that just changed
> (age == 0),
Why 'age == 0' means it is a good candidate to split? Because it means its
access frequency is anyway unstable? Or are there other reasons? More
clarification would be helpful.
> up to whatever budget is left under max_nr_regions.
> If a split turns out useless, the next merge cycle undoes it.
I'm again curious why the user cannot just increase max_nr_regions.
>
> Patch 2 adds a KUnit test for the case where nr_regions is already
> above max_nr_regions / 2.
Adding tests for new features is always nice, thank you!
I will review each patch in detail after the above high level questions are
answered.
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-05-21 14:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 4:52 [PATCH 0/2] mm/damon/core: detect internal variation above max_nr_regions/2 Jiayuan Chen
2026-05-21 4:52 ` [PATCH 1/2] mm/damon/core: split age==0 regions when nr_regions exceeds max/2 Jiayuan Chen
2026-05-21 4:52 ` [PATCH 2/2] mm/damon/tests/core-kunit: test split above max_nr_regions/2 Jiayuan Chen
2026-05-21 14:30 ` SeongJae Park [this message]
2026-05-21 15:07 ` [PATCH 0/2] mm/damon/core: detect internal variation " Jiayuan Chen
2026-05-22 2:42 ` SeongJae Park
2026-05-22 15:11 ` Jiayuan Chen
2026-05-23 1:43 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260521143049.82745-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=jiayuan.chen@linux.dev \
--cc=jiayuan.chen@shopee.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shu17az@gmail.com \
--cc=yanquanmin1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox