All of lore.kernel.org
 help / color / mirror / Atom feed
From: Akinobu Mita <akinobu.mita@gmail.com>
To: damon@lists.linux.dev
Cc: akinobu.mita@gmail.com
Subject: [PATCH] mm/damon/core: do not merge regions when the number of regions is small
Date: Mon, 11 Aug 2025 16:46:12 +0900	[thread overview]
Message-ID: <20250811074612.89804-1-akinobu.mita@gmail.com> (raw)

This change prevents adaptive region merging when the total number of
regions is less than the minimum number of regions setting.

Even in such cases, the kdamond_merge_regions() function must proceed by
setting the upper limit of the region size to zero to prevent any actual
region merging, since it is responsible for updating the region ages rather
than just merging regions.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 mm/damon/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 52a48c9316bc..34f1844094cf 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2247,9 +2247,15 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
 				  unsigned long sz_limit)
 {
 	struct damon_target *t;
-	unsigned int nr_regions;
+	unsigned int nr_regions = 0;
 	unsigned int max_thres;
 
+	damon_for_each_target(t, c)
+		nr_regions += damon_nr_regions(t);
+
+	if (nr_regions < c->attrs.min_nr_regions)
+		sz_limit = 0;
+
 	max_thres = c->attrs.aggr_interval /
 		(c->attrs.sample_interval ?  c->attrs.sample_interval : 1);
 	do {
-- 
2.43.0


             reply	other threads:[~2025-08-11  7:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-11  7:46 Akinobu Mita [this message]
2025-08-11 15:52 ` [PATCH] mm/damon/core: do not merge regions when the number of regions is small Sang-Heon Jeon
2025-08-12  4:21   ` Akinobu Mita
2025-08-11 19:26 ` SeongJae Park
2025-08-12  4:43   ` Akinobu Mita

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=20250811074612.89804-1-akinobu.mita@gmail.com \
    --to=akinobu.mita@gmail.com \
    --cc=damon@lists.linux.dev \
    /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 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.