Skip to contentSkip to conversation

mm/damon/core: modified and tunning damon_split_regions_of()

PATCH NAK JaeJoon Jung 2 participants 4 messages Jan 13 – Jan 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mm/damon/core: modified and tunning damon_split_regions_of()

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.

---
 mm/damon/core.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
mm/damon/core.c +6 -15
index f9fc0375890a..ff9af9d6a788 100644
@@ -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

maintainer Nacked-by on v1 1/2 NAK
#1 lore raw

Hello JaeJoon, thank you for continued interest in DAMON.

Quoted 13 lines · On Tue, 13 Jan 2026 21:16:42 +0900 JaeJoon Jung <[email protected]> wrote:

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:

Quoted 8 lines
                                                             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.

I was thinking about how to reply to this patch. Since it is taking unusually long time, let me add short comments for direct future of this patch.

The existing code uses random() for a reason. This change might break it. Can you further explain what was the point of the use of random(), and why this change is not breaking it?

Quoted 2 lines

Unless you can give me a convincing answer to my above question,

Same for your followup patch [1]. Btw, please send patches of same series as one thread from next time.

[1] https://lore.kernel.org/[email protected]

Thanks,
SJ

[...]

#2 lore raw
Quoted 23 lines · SeongJae Park

Hello JaeJoon, thank you for continued interest in DAMON.

Quoted 18 lines · On Tue, 13 Jan 2026 21:16:42 +0900 JaeJoon Jung <[email protected]> wrote:

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) ------------------>

Quoted 6 lines
Quoted 3 lines

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.

I was thinking about how to reply to this patch. Since it is taking unusually long time, let me add short comments for direct future of this patch.

After much thought, you ask a simple question below.

Quoted 4 lines

The existing code uses random() for a reason. This change might break it. Can you further explain what was the point of the use of random(), and why this change is not breaking it?

To find a needle in a haystack, is it right to keep poking around randomly?

Quoted 10 lines
Quoted 3 lines

Unless you can give me a convincing answer to my above question,

Same for your followup patch [1]. Btw, please send patches of same series as one thread from next time.

I sent you two after much deliberation so that you can see them clearly.

Thanks,
JaeJoon

Quoted 8 lines

[1] https://lore.kernel.org/[email protected]

Thanks,
SJ

[...]

maintainer Nacked-by NAK
#3 lore raw
Quoted 44 lines · On Thu, 15 Jan 2026 05:18:51 +0900 JaeJoon Jung <[email protected]> wrote:
Quoted 23 lines · SeongJae Park

Hello JaeJoon, thank you for continued interest in DAMON.

Quoted 18 lines · On Tue, 13 Jan 2026 21:16:42 +0900 JaeJoon Jung <[email protected]> wrote:

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) ------------------>

Quoted 6 lines
Quoted 3 lines

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.

I was thinking about how to reply to this patch. Since it is taking unusually long time, let me add short comments for direct future of this patch.

After much thought, you ask a simple question below.

Quoted 4 lines

The existing code uses random() for a reason. This change might break it. Can you further explain what was the point of the use of random(), and why this change is not breaking it?

To find a needle in a haystack, is it right to keep poking around randomly?

Quoted 4 lines
Quoted 3 lines
Quoted 8 lines
Quoted 6 lines

Unless you can give me a convincing answer to my above question,

Same for your followup patch [1]. Btw, please send patches of same series as one thread from next time.

I sent you two after much deliberation so that you can see them clearly.

Unfortunately what I asked are still not clearly answered to me. And based on our past conversations including the recent one that I acknowledged as a communication failure [1] and this thread, I expect asking you more questions will not work for me. I don't think that's someone's fault, but obviously that's the current situation. I will not ask you more questions for the reason, unless I get a reason to change my mind.

So, to make it crystal clear, for this patch and the one you posted together,

Thanks,
SJ

[1] https://lore.kernel.org/[email protected]

[...]