The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, jiayuan.chen@shopee.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Shu Anzai <shu17az@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mm/damon/core: split a fraction of regions when nr_regions exceeds max/2
Date: Fri, 26 Jun 2026 07:46:02 -0700	[thread overview]
Message-ID: <20260626144603.86521-1-sj@kernel.org> (raw)
In-Reply-To: <20260626085851.70754-2-jiayuan.chen@linux.dev>

On Fri, 26 Jun 2026 16:58:37 +0800 Jiayuan Chen <jiayuan.chen@linux.dev> wrote:

> From: Jiayuan Chen <jiayuan.chen@shopee.com>
> 
> kdamond_split_regions() returns early when nr_regions is above
> max_nr_regions / 2, leaving internal access variation inside a large
> region undetected.
> 
> Such a layout is common with damon-paddr on hugepage workloads or
> damon-vaddr on processes with a large anonymous mmap.
> 
> For example, with max_nr_regions == 1500, a target may end up with
> 799 small alternating-temperature regions plus one large region that
> absorbed a uniformly-accessed range during an earlier merge:
> 
> H:hot
> C:cold
> 
>       r1     r2     r3                 r800
>     HHHHHH|CCCCCC|HHHHHH|...|HHHHHH..........................|
> 
>     nr_regions = 800  >  max_nr_regions / 2 = 750
> 
> If a cold subarea later emerges inside r800:
> 
>       r1     r2     r3                 r800
>     HHHHHH|CCCCCC|HHHHHH|...|HHHHHH........CCCCCC.............|
> 
> The small regions cannot merge with each other (different access
> counts), so the budget stays full.  r800 cannot be split because
> nr_regions > max_nr_regions / 2 causes an early return.  The cold
> subarea is never discovered.
> 
> When nr_regions is above max_nr_regions / 2 but still under the
> maximum, split only a fraction of the regions instead of returning.
> One region in every 'max_nr_regions / budget' regions is split, where
> budget is the remaining room (max_nr_regions - nr_regions), starting
> from a rotating offset so different regions get picked over time.  The
> fraction shrinks as the budget shrinks, so the region count keeps
> refining while approaching max_nr_regions smoothly rather than
> overshooting it.  An unnecessary split is reverted by the next
> kdamond_merge_regions().

Looks good!

Thinking loud.  After this change, some users might surprise because the number
of regions became higher than before.  But it is still under the contracted
maximum number, and they will show better accuracy.  So I believe this is a
reasonable improvement rather than a breaking change.

Thank you for this patch, Jiayuan.

> 
> Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
> Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]

  reply	other threads:[~2026-06-26 14:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  8:58 [PATCH v2 0/2] mm/damon/core: detect internal variation above max_nr_regions/2 Jiayuan Chen
2026-06-26  8:58 ` [PATCH v2 1/2] mm/damon/core: split a fraction of regions when nr_regions exceeds max/2 Jiayuan Chen
2026-06-26 14:46   ` SeongJae Park [this message]
2026-06-26  8:58 ` [PATCH v2 2/2] mm/damon/tests/core-kunit: test split above max_nr_regions/2 Jiayuan Chen
2026-06-26 14:54   ` SeongJae Park
2026-06-26 14:59 ` [PATCH v2 0/2] mm/damon/core: detect internal variation " 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=20260626144603.86521-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 \
    /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