linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm/damon/core: modified and tunning damon_split_regions_of()
@ 2026-01-13 12:16 JaeJoon Jung
  0 siblings, 0 replies; only message in thread
From: JaeJoon Jung @ 2026-01-13 12:16 UTC (permalink / raw)
  To: sj; +Cc: JaeJoon Jung, damon, linux-mm, linux-kernel, rgbi3307

Before modification:
                                                             sz_region
    |--------|--------|--------||--------|--------|--------|--------|
nr_subs:     1        2        3        4        5                  9
split random:    <----------- (*] randmon        LOST -------------->

When dividing sz_region at rand, the random value may be small, such as
1 or 2.  At this time, there is a problem that only the front areas
corresponding to 1 and 2 are divided, and the remaining back area
becomes too wide.  If the area is too wide, there will be many missed
address access judgments.

After modification:
                                                             sz_region
    |--------|--------|--------|--------|--------|--------|--------||
nr_subs:     1        2        3        4        5                  9
split from   <------------ (sz_region / nr_subs) ------------------>

It is recommended to divide sz_region evenly in the ratio (sz_region /
nr_subs) rather than using rand.  In this way, if you decide nr_subs well,
you can logically match the number of divisions and their sizes.

Signed-off-by: JaeJoon Jung <rgbi3307@gmail.com>
---
 mm/damon/core.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index f9fc0375890a..ff9af9d6a788 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2394,27 +2394,18 @@ static void damon_split_regions_of(struct damon_target *t, int nr_subs,
 				  unsigned long min_sz_region)
 {
 	struct damon_region *r, *next;
-	unsigned long sz_region, sz_sub = 0;
+	unsigned long sz_region, sz_sub;
 	int i;

 	damon_for_each_region_safe(r, next, t) {
 		sz_region = damon_sz_region(r);
+		sz_sub = ALIGN_DOWN(sz_region / nr_subs, min_sz_region);

-		for (i = 0; i < nr_subs - 1 &&
-				sz_region > 2 * min_sz_region; i++) {
-			/*
-			 * Randomly select size of left sub-region to be at
-			 * least 10 percent and at most 90% of original region
-			 */
-			sz_sub = ALIGN_DOWN(damon_rand(1, 10) *
-					sz_region / 10, min_sz_region);
-			/* Do not allow blank region */
-			if (sz_sub == 0 || sz_sub >= sz_region)
-				continue;
+		if (sz_sub < min_sz_region)
+			continue;

-			damon_split_region_at(t, r, sz_sub);
-			sz_region = sz_sub;
-		}
+		for (i = 1; i < nr_subs; i++)
+			damon_split_region_at(t, r, sz_region - sz_sub * i);
 	}
 }

--
2.43.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-01-13 12:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-13 12:16 [PATCH 1/2] mm/damon/core: modified and tunning damon_split_regions_of() JaeJoon Jung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox