All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/damon/core: do not merge regions when the number of regions is small
@ 2025-08-11  7:46 Akinobu Mita
  2025-08-11 15:52 ` Sang-Heon Jeon
  2025-08-11 19:26 ` SeongJae Park
  0 siblings, 2 replies; 5+ messages in thread
From: Akinobu Mita @ 2025-08-11  7:46 UTC (permalink / raw)
  To: damon; +Cc: akinobu.mita

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-08-12  4:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11  7:46 [PATCH] mm/damon/core: do not merge regions when the number of regions is small Akinobu Mita
2025-08-11 15:52 ` Sang-Heon Jeon
2025-08-12  4:21   ` Akinobu Mita
2025-08-11 19:26 ` SeongJae Park
2025-08-12  4:43   ` Akinobu Mita

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.