mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions()
       [not found] <20261008151944.113714-1-suhaas@s-joshi.in>
@ 2026-10-08 15:19 ` Suhaas Joshi
  2026-10-08 15:33   ` Suhaas Joshi
  2026-10-09  7:43   ` SJ Park
  2026-10-08 15:19 ` [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at() Suhaas Joshi
  1 sibling, 2 replies; 9+ messages in thread
From: Suhaas Joshi @ 2026-10-08 15:19 UTC (permalink / raw)
  To: sj, akpm, aethernet65535; +Cc: damon, linux-mm, linux-kernel

While merging 2 regions, we iterate over the entire probe_hits[] array,
whose size is determined by the DAMON_MAX_PROBES macro. However, it is
possible that we have fewer probes installed than DAMON_MAX_PROBES. In such
cases, we end up making redundant iterations. Therefore, to remedy this,
iterate over the list of installed probes instead of iterating over the
entire array. For doing this, start accepting a struct damon_ctx in
damon_merge_two_regions(), and update calling functions to pass this
argument.

Update the damon_test_merge_two() test to use this new signature for
damon_merge_two_regions() as well.

Signed-off-by: Suhaas Joshi <suhaas@s-joshi.in>
---
 mm/damon/core.c             | 16 +++++++++++-----
 mm/damon/tests/core-kunit.h | 20 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index b63e60ef8990..fc202f90991b 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3524,20 +3524,26 @@ static void damon_verify_merge_two_regions(
 /*
  * Merge two adjacent regions into one region
  */
-static void damon_merge_two_regions(struct damon_target *t,
-		struct damon_region *l, struct damon_region *r)
+static void damon_merge_two_regions(struct damon_ctx *ctx,
+				    struct damon_target *t,
+				    struct damon_region *l,
+				    struct damon_region *r)
 {
 	unsigned long sz_l = damon_sz_region(l), sz_r = damon_sz_region(r);
 	int i;
+	struct damon_probe *p;
 
 	l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) /
 			(sz_l + sz_r);
 	l->age = (l->age * sz_l + r->age * sz_r) / (sz_l + sz_r);
 	l->ar.end = r->ar.end;
-	/* todo: do this for only installed probes */
-	for (i = 0; i < DAMON_MAX_PROBES; i++)
+
+	i = 0;
+	damon_for_each_probe(p, ctx) {
 		l->probe_hits[i] = (l->probe_hits[i] * sz_l + r->probe_hits[i]
 				* sz_r) / (sz_l + sz_r);
+		++i;
+	}
 	damon_verify_merge_two_regions(l, r);
 	damon_destroy_region(r, t);
 }
@@ -3590,7 +3596,7 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
 			goto set_prev_continue;
 		if (damon_sz_region(prev) + damon_sz_region(r) > sz_limit)
 			goto set_prev_continue;
-		damon_merge_two_regions(t, prev, r);
+		damon_merge_two_regions(ctx, t, prev, r);
 		continue;
 set_prev_continue:
 		prev = r;
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index ef146ca2ae8a..4e380c6c5eb2 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -182,13 +182,27 @@ static void damon_test_merge_two(struct kunit *test)
 {
 	struct damon_target *t;
 	struct damon_region *r, *r2, *r3;
+	struct damon_probe *p;
+	struct damon_ctx *ctx;
 	int i;
 
+	p = damon_new_probe();
+	if (!p)
+		kunit_skip(test, "probe alloc fail");
+	ctx = damon_new_ctx();
+	if (!ctx) {
+		damon_destroy_probe(p);
+		kunit_skip(test, "context alloc fail");
+	}
+	damon_add_probe(ctx, p);
 	t = damon_new_target();
-	if (!t)
+	if (!t) {
+		damon_destroy_ctx(ctx);
 		kunit_skip(test, "target alloc fail");
+	}
 	r = damon_new_region(0, 100);
 	if (!r) {
+		damon_destroy_ctx(ctx);
 		damon_free_target(t);
 		kunit_skip(test, "region alloc fail");
 	}
@@ -198,6 +212,7 @@ static void damon_test_merge_two(struct kunit *test)
 	damon_add_region(r, t);
 	r2 = damon_new_region(100, 300);
 	if (!r2) {
+		damon_destroy_ctx(ctx);
 		damon_free_target(t);
 		kunit_skip(test, "second region alloc fail");
 	}
@@ -206,7 +221,7 @@ static void damon_test_merge_two(struct kunit *test)
 	r2->age = 21;
 	damon_add_region(r2, t);
 
-	damon_merge_two_regions(t, r, r2);
+	damon_merge_two_regions(ctx, t, r, r2);
 	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
 	KUNIT_EXPECT_EQ(test, r->ar.end, 300ul);
 	KUNIT_EXPECT_EQ(test, r->nr_accesses, 16u);
@@ -220,6 +235,7 @@ static void damon_test_merge_two(struct kunit *test)
 	}
 	KUNIT_EXPECT_EQ(test, i, 1);
 
+	damon_destroy_ctx(ctx);
 	damon_free_target(t);
 }
 
-- 
2.55.0


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

* [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
       [not found] <20261008151944.113714-1-suhaas@s-joshi.in>
  2026-10-08 15:19 ` [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions() Suhaas Joshi
@ 2026-10-08 15:19 ` Suhaas Joshi
  2026-10-09  2:40   ` kernel test robot
  2026-10-09  4:06   ` kernel test robot
  1 sibling, 2 replies; 9+ messages in thread
From: Suhaas Joshi @ 2026-10-08 15:19 UTC (permalink / raw)
  To: sj, akpm, aethernet65535; +Cc: damon, linux-mm, linux-kernel

In damon_split_region_at(), we copy the entire probe_hits[] and
last_probe_hits[] arrays of DAMON_MAX_PROBES size. However it is possible
that the number of probes installed is less than DAMON_MAX_PROBES, in which
case one or more iterations is/are redundant. To remedy this, iterate over
only as many times as the number of installed probes. To do so, accept a
struct damon_ctx pointer in damon_split_region_at(), and update all
invocations of the function to pass the new argument.

Also update damon_test_split_at() and damos_test_filter_out() in
core-kunit.h to supply a context to function paths that call
damon_split_region_at().

Signed-off-by: Suhaas Joshi <suhaas@s-joshi.in>
---
 mm/damon/core.c             | 45 +++++++++++++++++++---------------
 mm/damon/tests/core-kunit.h | 48 ++++++++++++++++++++++++++++++-------
 2 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index fc202f90991b..9e5a19c2a19d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2051,8 +2051,8 @@ static unsigned long damon_region_sz_limit(struct damon_ctx *ctx)
 	return sz;
 }
 
-static int damon_split_region_at(struct damon_target *t,
-				  struct damon_region *r, unsigned long sz_r);
+static int damon_split_region_at(struct damon_ctx *ctx, struct damon_target *t,
+				 struct damon_region *r, unsigned long sz_r);
 
 /*
  * damon_apply_min_nr_regions() - Make effect of min_nr_regions parameter.
@@ -2077,7 +2077,7 @@ static unsigned long damon_apply_min_nr_regions(struct damon_ctx *ctx)
 	damon_for_each_target(t, ctx) {
 		damon_for_each_region_safe(r, next, t) {
 			while (damon_sz_region(r) > max_region_sz) {
-				if (damon_split_region_at(t, r, max_region_sz))
+				if (damon_split_region_at(ctx, t, r, max_region_sz))
 					goto out;
 				r = damon_next_region(r);
 			}
@@ -2474,6 +2474,7 @@ static bool damos_valid_target(struct damon_ctx *c, struct damon_region *r,
 /*
  * damos_skip_charged_region() - Check if the given region or starting part of
  * it is already charged for the DAMOS quota.
+ * @ctx: The pointer to the context.
  * @t:	The target of the region.
  * @rp:	The pointer to the region.
  * @s:	The scheme to be applied.
@@ -2496,9 +2497,10 @@ static bool damos_valid_target(struct damon_ctx *c, struct damon_region *r,
  *
  * Return: true if the region should be skipped, false otherwise.
  */
-static bool damos_skip_charged_region(struct damon_target *t,
-		struct damon_region *r, struct damos *s,
-		unsigned long min_region_sz)
+static bool damos_skip_charged_region(struct damon_ctx *ctx,
+				      struct damon_target *t,
+				      struct damon_region *r, struct damos *s,
+				      unsigned long min_region_sz)
 {
 	struct damos_quota *quota = &s->quota;
 	unsigned long sz_to_skip;
@@ -2525,7 +2527,7 @@ static bool damos_skip_charged_region(struct damon_target *t,
 				}
 				sz_to_skip = min_region_sz;
 			}
-			damon_split_region_at(t, r, sz_to_skip);
+			damon_split_region_at(ctx, t, r, sz_to_skip);
 			skip = true;
 		}
 	}
@@ -2583,12 +2585,12 @@ static bool damos_filter_match(struct damon_ctx *ctx, struct damon_target *t,
 		}
 		/* start before the range and overlap */
 		if (r->ar.start < start) {
-			damon_split_region_at(t, r, start - r->ar.start);
+			damon_split_region_at(ctx, t, r, start - r->ar.start);
 			matched = false;
 			break;
 		}
 		/* start inside the range */
-		damon_split_region_at(t, r, end - r->ar.start);
+		damon_split_region_at(ctx, t, r, end - r->ar.start);
 		matched = true;
 		break;
 	case DAMOS_FILTER_TYPE_PROBE_HITS_WSUM:
@@ -2781,7 +2783,7 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
 					c->min_region_sz);
 			if (!sz)
 				goto update_stat;
-			if (damon_split_region_at(t, r, sz))
+			if (damon_split_region_at(c, t, r, sz))
 				goto update_stat;
 		}
 		if (damos_core_filter_out(c, t, r, s))
@@ -2828,7 +2830,7 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
 		if (damos_quota_is_full(quota, c->min_region_sz))
 			continue;
 
-		if (damos_skip_charged_region(t, r, s, c->min_region_sz))
+		if (damos_skip_charged_region(c, t, r, s, c->min_region_sz))
 			continue;
 
 		if (s->max_nr_snapshots &&
@@ -3666,15 +3668,18 @@ static void damon_verify_split_region_at(struct damon_region *r,
 /*
  * Split a region in two
  *
+ * ctx		pointer to the region's context
  * r		the region to be split
  * sz_r		size of the first sub-region that will be made
  *
  * Return: 0 on success, negative error code otherwise.
  */
-static int damon_split_region_at(struct damon_target *t,
-				  struct damon_region *r, unsigned long sz_r)
+static int damon_split_region_at(struct damon_ctx *ctx, struct damon_target *t,
+				 struct damon_region *r, unsigned long sz_r)
 {
 	struct damon_region *new;
+	struct damon_probe *p;
+	int i;
 
 	damon_verify_split_region_at(r, sz_r);
 	new = damon_new_region(r->ar.start + sz_r, r->ar.end);
@@ -3686,11 +3691,13 @@ static int damon_split_region_at(struct damon_target *t,
 	new->age = r->age;
 	new->last_nr_accesses = r->last_nr_accesses;
 	new->nr_accesses = r->nr_accesses;
-	/* todo: do this for only installed probes */
-	memcpy(new->probe_hits, r->probe_hits, sizeof(r->probe_hits));
-	memcpy(new->last_probe_hits, r->last_probe_hits,
-			sizeof(r->last_probe_hits));
 
+	i = 0;
+	damon_for_each_probe(p, ctx) {
+		new->probe_hits[i] = r->probe_hits[i];
+		new->last_probe_hits[i] = r->last_probe_hits[i];
+		++i;
+	}
 	damon_insert_region(new, r, damon_next_region(r), t);
 	return 0;
 }
@@ -3719,7 +3726,7 @@ static void damon_split_regions_of(struct damon_ctx *ctx,
 			if (sz_sub == 0 || sz_sub >= sz_region)
 				continue;
 
-			damon_split_region_at(t, r, sz_sub);
+			damon_split_region_at(ctx, t, r, sz_sub);
 			sz_region = sz_sub;
 		}
 	}
@@ -3751,7 +3758,7 @@ static void damon_split_some_regions(struct damon_ctx *ctx,
 			if (sz_sub == 0 || sz_sub >= sz_region)
 				continue;
 
-			damon_split_region_at(t, r, sz_sub);
+			damon_split_region_at(ctx, t, r, sz_sub);
 		}
 	}
 }
diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
index 4e380c6c5eb2..b942598e8dc2 100644
--- a/mm/damon/tests/core-kunit.h
+++ b/mm/damon/tests/core-kunit.h
@@ -141,12 +141,26 @@ static void damon_test_split_at(struct kunit *test)
 {
 	struct damon_target *t;
 	struct damon_region *r, *r_new;
+	struct damon_ctx *ctx;
+	struct damon_probe *p;
 
+	p = damon_new_probe();
+	if (!p)
+		kunit_skip(test, "probe alloc fail");
+	ctx = damon_new_ctx();
+	if (!ctx) {
+		damon_destroy_probe(p);
+		kunit_skip(test, "context alloc fail");
+	}
+	damon_add_probe(ctx, p);
 	t = damon_new_target();
-	if (!t)
+	if (!t) {
+		damon_destroy_ctx(ctx);
 		kunit_skip(test, "target alloc fail");
+	}
 	r = damon_new_region(0, 100);
 	if (!r) {
+		damon_destroy_ctx(ctx);
 		damon_free_target(t);
 		kunit_skip(test, "region alloc fail");
 	}
@@ -156,7 +170,7 @@ static void damon_test_split_at(struct kunit *test)
 	r->last_probe_hits[0] = 3;
 	r->age = 10;
 	damon_add_region(r, t);
-	damon_split_region_at(t, r, 25);
+	damon_split_region_at(ctx, t, r, 25);
 	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 2);
 	if (damon_nr_regions(t) != 2)
 		goto out;
@@ -176,6 +190,7 @@ static void damon_test_split_at(struct kunit *test)
 
 out:
 	damon_free_target(t);
+	damon_destroy_ctx(ctx);
 }
 
 static void damon_test_merge_two(struct kunit *test)
@@ -1799,19 +1814,35 @@ static void damos_test_filter_out(struct kunit *test)
 	struct damon_target *t;
 	struct damon_region *r, *r2;
 	struct damos_filter *f;
+	struct damon_ctx *ctx;
+	struct damon_probe *p;
+
+	p = damon_new_probe();
+	if (!p)
+		kunit_skip(test, "probe alloc fail");
+	ctx = damon_new_ctx();
+	if (!ctx) {
+		damon_destroy_probe(p);
+		kunit_skip(test, "context alloc fail");
+	}
+	damon_add_probe(ctx, p);
 
 	f = damos_new_filter(DAMOS_FILTER_TYPE_ADDR, true, false);
-	if (!f)
+	if (!f) {
+		damon_destroy_ctx(ctx);
 		kunit_skip(test, "filter alloc fail");
+	}
 	f->addr_range = (struct damon_addr_range){.start = 2, .end = 6};
 
 	t = damon_new_target();
 	if (!t) {
+		damon_destroy_ctx(ctx);
 		damos_destroy_filter(f);
 		kunit_skip(test, "target alloc fail");
 	}
 	r = damon_new_region(3, 5);
 	if (!r) {
+		damon_destroy_ctx(ctx);
 		damos_destroy_filter(f);
 		damon_free_target(t);
 		kunit_skip(test, "region alloc fail");
@@ -1819,27 +1850,27 @@ static void damos_test_filter_out(struct kunit *test)
 	damon_add_region(r, t);
 
 	/* region in the range */
-	KUNIT_EXPECT_TRUE(test, damos_filter_match(NULL, t, r, f, 1));
+	KUNIT_EXPECT_TRUE(test, damos_filter_match(ctx, t, r, f, 1));
 	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1);
 
 	/* region before the range */
 	r->ar.start = 1;
 	r->ar.end = 2;
 	KUNIT_EXPECT_FALSE(test,
-			damos_filter_match(NULL, t, r, f, 1));
+			damos_filter_match(ctx, t, r, f, 1));
 	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1);
 
 	/* region after the range */
 	r->ar.start = 6;
 	r->ar.end = 8;
 	KUNIT_EXPECT_FALSE(test,
-			damos_filter_match(NULL, t, r, f, 1));
+			damos_filter_match(ctx, t, r, f, 1));
 	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1);
 
 	/* region started before the range */
 	r->ar.start = 1;
 	r->ar.end = 4;
-	KUNIT_EXPECT_FALSE(test, damos_filter_match(NULL, t, r, f, 1));
+	KUNIT_EXPECT_FALSE(test, damos_filter_match(ctx, t, r, f, 1));
 	/* filter should have split the region */
 	KUNIT_EXPECT_EQ(test, r->ar.start, 1);
 	KUNIT_EXPECT_EQ(test, r->ar.end, 2);
@@ -1855,7 +1886,7 @@ static void damos_test_filter_out(struct kunit *test)
 	r->ar.start = 2;
 	r->ar.end = 8;
 	KUNIT_EXPECT_TRUE(test,
-			damos_filter_match(NULL, t, r, f, 1));
+			damos_filter_match(ctx, t, r, f, 1));
 	/* filter should have split the region */
 	KUNIT_EXPECT_EQ(test, r->ar.start, 2);
 	KUNIT_EXPECT_EQ(test, r->ar.end, 6);
@@ -1868,6 +1899,7 @@ static void damos_test_filter_out(struct kunit *test)
 	damon_destroy_region(r2, t);
 
 out:
+	damon_destroy_ctx(ctx);
 	damon_free_target(t);
 	damos_free_filter(f);
 }
-- 
2.55.0


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

* Re: [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions()
  2026-10-08 15:19 ` [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions() Suhaas Joshi
@ 2026-10-08 15:33   ` Suhaas Joshi
  2026-10-09  7:46     ` SJ Park
  2026-10-09  7:43   ` SJ Park
  1 sibling, 1 reply; 9+ messages in thread
From: Suhaas Joshi @ 2026-10-08 15:33 UTC (permalink / raw)
  To: sj, akpm, aethernet65535; +Cc: damon, linux-mm, linux-kernel

For some inexplicable reason, the cover-letter hasn't been sent again.

I am just adding the changelog here, in case the cover letter never arrives.

Changelog v1->v2:

1. Simplified patch 1's commit message to make it clearer 
   (Liew's suggestion)
2. Added comment docs for extra arguments I am adding to functions
   (SJ's suggestion)
3. Destroyed the context in case r2 allocation fails in damon_test_merge_two()
   (Sashiko/Liew/SJ suggestion)
4. Wrapped lines at 80 characters 
   (SJ's suggestion)

As for why the cover-letter isn't being sent, I have no idea. Everything seems
fine during `git send-email --dry-run`. Also seemed fine when I sent the series
to myself as a test.
Apologies for the inconvenience. I will make sure I fix this issue before sending
v3 or any more series in the future.

Thanks
Suhaas

On Thu, Oct 08, 2026 at 08:49:25PM +0530, Suhaas Joshi wrote:
> While merging 2 regions, we iterate over the entire probe_hits[] array,
> whose size is determined by the DAMON_MAX_PROBES macro. However, it is
> possible that we have fewer probes installed than DAMON_MAX_PROBES. In such
> cases, we end up making redundant iterations. Therefore, to remedy this,
> iterate over the list of installed probes instead of iterating over the
> entire array. For doing this, start accepting a struct damon_ctx in
> damon_merge_two_regions(), and update calling functions to pass this
> argument.
> 
> Update the damon_test_merge_two() test to use this new signature for
> damon_merge_two_regions() as well.
> 
> Signed-off-by: Suhaas Joshi <suhaas@s-joshi.in>
> ---
>  mm/damon/core.c             | 16 +++++++++++-----
>  mm/damon/tests/core-kunit.h | 20 ++++++++++++++++++--
>  2 files changed, 29 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index b63e60ef8990..fc202f90991b 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3524,20 +3524,26 @@ static void damon_verify_merge_two_regions(
>  /*
>   * Merge two adjacent regions into one region
>   */
> -static void damon_merge_two_regions(struct damon_target *t,
> -		struct damon_region *l, struct damon_region *r)
> +static void damon_merge_two_regions(struct damon_ctx *ctx,
> +				    struct damon_target *t,
> +				    struct damon_region *l,
> +				    struct damon_region *r)
>  {
>  	unsigned long sz_l = damon_sz_region(l), sz_r = damon_sz_region(r);
>  	int i;
> +	struct damon_probe *p;
>  
>  	l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) /
>  			(sz_l + sz_r);
>  	l->age = (l->age * sz_l + r->age * sz_r) / (sz_l + sz_r);
>  	l->ar.end = r->ar.end;
> -	/* todo: do this for only installed probes */
> -	for (i = 0; i < DAMON_MAX_PROBES; i++)
> +
> +	i = 0;
> +	damon_for_each_probe(p, ctx) {
>  		l->probe_hits[i] = (l->probe_hits[i] * sz_l + r->probe_hits[i]
>  				* sz_r) / (sz_l + sz_r);
> +		++i;
> +	}
>  	damon_verify_merge_two_regions(l, r);
>  	damon_destroy_region(r, t);
>  }
> @@ -3590,7 +3596,7 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
>  			goto set_prev_continue;
>  		if (damon_sz_region(prev) + damon_sz_region(r) > sz_limit)
>  			goto set_prev_continue;
> -		damon_merge_two_regions(t, prev, r);
> +		damon_merge_two_regions(ctx, t, prev, r);
>  		continue;
>  set_prev_continue:
>  		prev = r;
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index ef146ca2ae8a..4e380c6c5eb2 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -182,13 +182,27 @@ static void damon_test_merge_two(struct kunit *test)
>  {
>  	struct damon_target *t;
>  	struct damon_region *r, *r2, *r3;
> +	struct damon_probe *p;
> +	struct damon_ctx *ctx;
>  	int i;
>  
> +	p = damon_new_probe();
> +	if (!p)
> +		kunit_skip(test, "probe alloc fail");
> +	ctx = damon_new_ctx();
> +	if (!ctx) {
> +		damon_destroy_probe(p);
> +		kunit_skip(test, "context alloc fail");
> +	}
> +	damon_add_probe(ctx, p);
>  	t = damon_new_target();
> -	if (!t)
> +	if (!t) {
> +		damon_destroy_ctx(ctx);
>  		kunit_skip(test, "target alloc fail");
> +	}
>  	r = damon_new_region(0, 100);
>  	if (!r) {
> +		damon_destroy_ctx(ctx);
>  		damon_free_target(t);
>  		kunit_skip(test, "region alloc fail");
>  	}
> @@ -198,6 +212,7 @@ static void damon_test_merge_two(struct kunit *test)
>  	damon_add_region(r, t);
>  	r2 = damon_new_region(100, 300);
>  	if (!r2) {
> +		damon_destroy_ctx(ctx);
>  		damon_free_target(t);
>  		kunit_skip(test, "second region alloc fail");
>  	}
> @@ -206,7 +221,7 @@ static void damon_test_merge_two(struct kunit *test)
>  	r2->age = 21;
>  	damon_add_region(r2, t);
>  
> -	damon_merge_two_regions(t, r, r2);
> +	damon_merge_two_regions(ctx, t, r, r2);
>  	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
>  	KUNIT_EXPECT_EQ(test, r->ar.end, 300ul);
>  	KUNIT_EXPECT_EQ(test, r->nr_accesses, 16u);
> @@ -220,6 +235,7 @@ static void damon_test_merge_two(struct kunit *test)
>  	}
>  	KUNIT_EXPECT_EQ(test, i, 1);
>  
> +	damon_destroy_ctx(ctx);
>  	damon_free_target(t);
>  }
>  
> -- 
> 2.55.0
> 

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

* Re: [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
  2026-10-08 15:19 ` [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at() Suhaas Joshi
@ 2026-10-09  2:40   ` kernel test robot
  2026-10-09  8:21     ` SJ Park
  2026-10-09  4:06   ` kernel test robot
  1 sibling, 1 reply; 9+ messages in thread
From: kernel test robot @ 2026-10-09  2:40 UTC (permalink / raw)
  To: Suhaas Joshi, sj, akpm, aethernet65535
  Cc: oe-kbuild-all, damon, linux-mm, linux-kernel

Hi Suhaas,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Suhaas-Joshi/mm-damon-core-Copy-only-installed-probe-in-damon_split_region_at/20261008-204926
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20261008151944.113714-3-suhaas%40s-joshi.in
patch subject: [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
config: csky-randconfig-1001-20261009 (https://download.01.org/0day-ci/archive/20261009/202610091039.fhMXCn7d-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261009/202610091039.fhMXCn7d-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610091039.fhMXCn7d-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from mm/damon/core.c:4295:
   mm/damon/tests/core-kunit.h: In function 'damon_test_last_region_quota_reset':
>> mm/damon/tests/core-kunit.h:2519:38: error: passing argument 1 of 'damos_skip_charged_region' from incompatible pointer type [-Werror=incompatible-pointer-types]
    2519 |  skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                      ^
         |                                      |
         |                                      struct damon_target *
   mm/damon/core.c:2500:57: note: expected 'struct damon_ctx *' but argument is of type 'struct damon_target *'
    2500 | static bool damos_skip_charged_region(struct damon_ctx *ctx,
         |                                       ~~~~~~~~~~~~~~~~~~^~~
   In file included from mm/damon/core.c:4295:
   mm/damon/tests/core-kunit.h:2519:41: error: passing argument 2 of 'damos_skip_charged_region' from incompatible pointer type [-Werror=incompatible-pointer-types]
    2519 |  skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                         ^~
         |                                         |
         |                                         struct damon_region *
   mm/damon/core.c:2501:32: note: expected 'struct damon_target *' but argument is of type 'struct damon_region *'
    2501 |           struct damon_target *t,
         |           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from mm/damon/core.c:4295:
   mm/damon/tests/core-kunit.h:2519:45: error: passing argument 3 of 'damos_skip_charged_region' from incompatible pointer type [-Werror=incompatible-pointer-types]
    2519 |  skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                             ^~
         |                                             |
         |                                             struct damos *
   mm/damon/core.c:2502:32: note: expected 'struct damon_region *' but argument is of type 'struct damos *'
    2502 |           struct damon_region *r, struct damos *s,
         |           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from mm/damon/core.c:4295:
>> mm/damon/tests/core-kunit.h:2519:49: warning: passing argument 4 of 'damos_skip_charged_region' makes pointer from integer without a cast [-Wint-conversion]
    2519 |  skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                                 ^~~~~~~~~~~~~
         |                                                 |
         |                                                 long unsigned int
   mm/damon/core.c:2502:49: note: expected 'struct damos *' but argument is of type 'long unsigned int'
    2502 |           struct damon_region *r, struct damos *s,
         |                                   ~~~~~~~~~~~~~~^
   In file included from mm/damon/core.c:4295:
>> mm/damon/tests/core-kunit.h:2519:12: error: too few arguments to function 'damos_skip_charged_region'
    2519 |  skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |            ^~~~~~~~~~~~~~~~~~~~~~~~~
   mm/damon/core.c:2500:13: note: declared here
    2500 | static bool damos_skip_charged_region(struct damon_ctx *ctx,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/damos_skip_charged_region +2519 mm/damon/tests/core-kunit.h

79500f5843f453 Donggeun Yoo 2026-09-28  2489  
18793c04abe665 Liew Rui Yan 2026-10-05  2490  static void damon_test_last_region_quota_reset(struct kunit *test)
18793c04abe665 Liew Rui Yan 2026-10-05  2491  {
18793c04abe665 Liew Rui Yan 2026-10-05  2492  	struct damos s = {0};
18793c04abe665 Liew Rui Yan 2026-10-05  2493  	struct damon_target *t;
18793c04abe665 Liew Rui Yan 2026-10-05  2494  	struct damon_region *r1, *r2;
18793c04abe665 Liew Rui Yan 2026-10-05  2495  	unsigned long min_region_sz = 1;
18793c04abe665 Liew Rui Yan 2026-10-05  2496  	bool skipped;
18793c04abe665 Liew Rui Yan 2026-10-05  2497  
18793c04abe665 Liew Rui Yan 2026-10-05  2498  	t = damon_new_target();
18793c04abe665 Liew Rui Yan 2026-10-05  2499  	if (!t)
18793c04abe665 Liew Rui Yan 2026-10-05  2500  		kunit_skip(test, "target alloc fail");
18793c04abe665 Liew Rui Yan 2026-10-05  2501  
18793c04abe665 Liew Rui Yan 2026-10-05  2502  	r1 = damon_new_region(0, 100);
18793c04abe665 Liew Rui Yan 2026-10-05  2503  	if (!r1) {
18793c04abe665 Liew Rui Yan 2026-10-05  2504  		damon_free_target(t);
18793c04abe665 Liew Rui Yan 2026-10-05  2505  		kunit_skip(test, "region 1 alloc fail");
18793c04abe665 Liew Rui Yan 2026-10-05  2506  	}
18793c04abe665 Liew Rui Yan 2026-10-05  2507  	damon_add_region(r1, t);
18793c04abe665 Liew Rui Yan 2026-10-05  2508  
18793c04abe665 Liew Rui Yan 2026-10-05  2509  	r2 = damon_new_region(100, 200);
18793c04abe665 Liew Rui Yan 2026-10-05  2510  	if (!r2) {
18793c04abe665 Liew Rui Yan 2026-10-05  2511  		damon_free_target(t);
18793c04abe665 Liew Rui Yan 2026-10-05  2512  		kunit_skip(test, "region 2 alloc fail");
18793c04abe665 Liew Rui Yan 2026-10-05  2513  	}
18793c04abe665 Liew Rui Yan 2026-10-05  2514  	damon_add_region(r2, t);
18793c04abe665 Liew Rui Yan 2026-10-05  2515  
18793c04abe665 Liew Rui Yan 2026-10-05  2516  	s.quota.charge_target_from = t;
18793c04abe665 Liew Rui Yan 2026-10-05  2517  	s.quota.charge_addr_from = r1->ar.end;
18793c04abe665 Liew Rui Yan 2026-10-05  2518  
18793c04abe665 Liew Rui Yan 2026-10-05 @2519  	skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
18793c04abe665 Liew Rui Yan 2026-10-05  2520  
18793c04abe665 Liew Rui Yan 2026-10-05  2521  	/* 'r2' is not processed, it should not skip */
18793c04abe665 Liew Rui Yan 2026-10-05  2522  	KUNIT_EXPECT_EQ(test, skipped, false);
18793c04abe665 Liew Rui Yan 2026-10-05  2523  
18793c04abe665 Liew Rui Yan 2026-10-05  2524  	/* 'r2' is last region, it should reset charge_{target,addr}_from */
18793c04abe665 Liew Rui Yan 2026-10-05  2525  	KUNIT_EXPECT_PTR_EQ(test, s.quota.charge_target_from, NULL);
18793c04abe665 Liew Rui Yan 2026-10-05  2526  	KUNIT_EXPECT_EQ(test, s.quota.charge_addr_from, 0);
18793c04abe665 Liew Rui Yan 2026-10-05  2527  
18793c04abe665 Liew Rui Yan 2026-10-05  2528  	damon_free_target(t);
18793c04abe665 Liew Rui Yan 2026-10-05  2529  }
18793c04abe665 Liew Rui Yan 2026-10-05  2530  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
  2026-10-08 15:19 ` [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at() Suhaas Joshi
  2026-10-09  2:40   ` kernel test robot
@ 2026-10-09  4:06   ` kernel test robot
  1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2026-10-09  4:06 UTC (permalink / raw)
  To: Suhaas Joshi, sj, akpm, aethernet65535
  Cc: oe-kbuild-all, damon, linux-mm, linux-kernel

Hi Suhaas,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Suhaas-Joshi/mm-damon-core-Copy-only-installed-probe-in-damon_split_region_at/20261008-204926
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20261008151944.113714-3-suhaas%40s-joshi.in
patch subject: [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
config: x86_64-randconfig-1000-20261009 (https://download.01.org/0day-ci/archive/20261009/202610091227.PIPVB0PW-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261009/202610091227.PIPVB0PW-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610091227.PIPVB0PW-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from mm/damon/core.c:4295:
   mm/damon/tests/core-kunit.h: In function 'damon_test_last_region_quota_reset':
   mm/damon/tests/core-kunit.h:2519:45: error: passing argument 1 of 'damos_skip_charged_region' from incompatible pointer type [-Wincompatible-pointer-types]
    2519 |         skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                             ^
         |                                             |
         |                                             struct damon_target *
   mm/damon/core.c:2500:57: note: expected 'struct damon_ctx *' but argument is of type 'struct damon_target *'
    2500 | static bool damos_skip_charged_region(struct damon_ctx *ctx,
         |                                       ~~~~~~~~~~~~~~~~~~^~~
   mm/damon/tests/core-kunit.h:2519:48: error: passing argument 2 of 'damos_skip_charged_region' from incompatible pointer type [-Wincompatible-pointer-types]
    2519 |         skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                                ^~
         |                                                |
         |                                                struct damon_region *
   mm/damon/core.c:2501:60: note: expected 'struct damon_target *' but argument is of type 'struct damon_region *'
    2501 |                                       struct damon_target *t,
         |                                       ~~~~~~~~~~~~~~~~~~~~~^
   mm/damon/tests/core-kunit.h:2519:52: error: passing argument 3 of 'damos_skip_charged_region' from incompatible pointer type [-Wincompatible-pointer-types]
    2519 |         skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                                    ^~
         |                                                    |
         |                                                    struct damos *
   mm/damon/core.c:2502:60: note: expected 'struct damon_region *' but argument is of type 'struct damos *'
    2502 |                                       struct damon_region *r, struct damos *s,
         |                                       ~~~~~~~~~~~~~~~~~~~~~^
>> mm/damon/tests/core-kunit.h:2519:56: error: passing argument 4 of 'damos_skip_charged_region' makes pointer from integer without a cast [-Wint-conversion]
    2519 |         skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                                                        ^~~~~~~~~~~~~
         |                                                        |
         |                                                        long unsigned int
   mm/damon/core.c:2502:77: note: expected 'struct damos *' but argument is of type 'long unsigned int'
    2502 |                                       struct damon_region *r, struct damos *s,
         |                                                               ~~~~~~~~~~~~~~^
   mm/damon/tests/core-kunit.h:2519:19: error: too few arguments to function 'damos_skip_charged_region'
    2519 |         skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
         |                   ^~~~~~~~~~~~~~~~~~~~~~~~~
   mm/damon/core.c:2500:13: note: declared here
    2500 | static bool damos_skip_charged_region(struct damon_ctx *ctx,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~


vim +/damos_skip_charged_region +2519 mm/damon/tests/core-kunit.h

79500f5843f453 Donggeun Yoo 2026-09-28  2489  
18793c04abe665 Liew Rui Yan 2026-10-05  2490  static void damon_test_last_region_quota_reset(struct kunit *test)
18793c04abe665 Liew Rui Yan 2026-10-05  2491  {
18793c04abe665 Liew Rui Yan 2026-10-05  2492  	struct damos s = {0};
18793c04abe665 Liew Rui Yan 2026-10-05  2493  	struct damon_target *t;
18793c04abe665 Liew Rui Yan 2026-10-05  2494  	struct damon_region *r1, *r2;
18793c04abe665 Liew Rui Yan 2026-10-05  2495  	unsigned long min_region_sz = 1;
18793c04abe665 Liew Rui Yan 2026-10-05  2496  	bool skipped;
18793c04abe665 Liew Rui Yan 2026-10-05  2497  
18793c04abe665 Liew Rui Yan 2026-10-05  2498  	t = damon_new_target();
18793c04abe665 Liew Rui Yan 2026-10-05  2499  	if (!t)
18793c04abe665 Liew Rui Yan 2026-10-05  2500  		kunit_skip(test, "target alloc fail");
18793c04abe665 Liew Rui Yan 2026-10-05  2501  
18793c04abe665 Liew Rui Yan 2026-10-05  2502  	r1 = damon_new_region(0, 100);
18793c04abe665 Liew Rui Yan 2026-10-05  2503  	if (!r1) {
18793c04abe665 Liew Rui Yan 2026-10-05  2504  		damon_free_target(t);
18793c04abe665 Liew Rui Yan 2026-10-05  2505  		kunit_skip(test, "region 1 alloc fail");
18793c04abe665 Liew Rui Yan 2026-10-05  2506  	}
18793c04abe665 Liew Rui Yan 2026-10-05  2507  	damon_add_region(r1, t);
18793c04abe665 Liew Rui Yan 2026-10-05  2508  
18793c04abe665 Liew Rui Yan 2026-10-05  2509  	r2 = damon_new_region(100, 200);
18793c04abe665 Liew Rui Yan 2026-10-05  2510  	if (!r2) {
18793c04abe665 Liew Rui Yan 2026-10-05  2511  		damon_free_target(t);
18793c04abe665 Liew Rui Yan 2026-10-05  2512  		kunit_skip(test, "region 2 alloc fail");
18793c04abe665 Liew Rui Yan 2026-10-05  2513  	}
18793c04abe665 Liew Rui Yan 2026-10-05  2514  	damon_add_region(r2, t);
18793c04abe665 Liew Rui Yan 2026-10-05  2515  
18793c04abe665 Liew Rui Yan 2026-10-05  2516  	s.quota.charge_target_from = t;
18793c04abe665 Liew Rui Yan 2026-10-05  2517  	s.quota.charge_addr_from = r1->ar.end;
18793c04abe665 Liew Rui Yan 2026-10-05  2518  
18793c04abe665 Liew Rui Yan 2026-10-05 @2519  	skipped = damos_skip_charged_region(t, r2, &s, min_region_sz);
18793c04abe665 Liew Rui Yan 2026-10-05  2520  
18793c04abe665 Liew Rui Yan 2026-10-05  2521  	/* 'r2' is not processed, it should not skip */
18793c04abe665 Liew Rui Yan 2026-10-05  2522  	KUNIT_EXPECT_EQ(test, skipped, false);
18793c04abe665 Liew Rui Yan 2026-10-05  2523  
18793c04abe665 Liew Rui Yan 2026-10-05  2524  	/* 'r2' is last region, it should reset charge_{target,addr}_from */
18793c04abe665 Liew Rui Yan 2026-10-05  2525  	KUNIT_EXPECT_PTR_EQ(test, s.quota.charge_target_from, NULL);
18793c04abe665 Liew Rui Yan 2026-10-05  2526  	KUNIT_EXPECT_EQ(test, s.quota.charge_addr_from, 0);
18793c04abe665 Liew Rui Yan 2026-10-05  2527  
18793c04abe665 Liew Rui Yan 2026-10-05  2528  	damon_free_target(t);
18793c04abe665 Liew Rui Yan 2026-10-05  2529  }
18793c04abe665 Liew Rui Yan 2026-10-05  2530  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions()
  2026-10-08 15:19 ` [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions() Suhaas Joshi
  2026-10-08 15:33   ` Suhaas Joshi
@ 2026-10-09  7:43   ` SJ Park
  1 sibling, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-10-09  7:43 UTC (permalink / raw)
  To: Suhaas Joshi; +Cc: SJ Park, akpm, aethernet65535, damon, linux-mm, linux-kernel

Hello Suhaas,

On Thu,  8 Oct 2026 20:49:25 +0530 Suhaas Joshi <suhaas@s-joshi.in> wrote:

> While merging 2 regions, we iterate over the entire probe_hits[] array,
> whose size is determined by the DAMON_MAX_PROBES macro. However, it is
> possible that we have fewer probes installed than DAMON_MAX_PROBES. In such
> cases, we end up making redundant iterations. Therefore, to remedy this,
> iterate over the list of installed probes instead of iterating over the
> entire array. For doing this, start accepting a struct damon_ctx in
> damon_merge_two_regions(), and update calling functions to pass this
> argument.
> 
> Update the damon_test_merge_two() test to use this new signature for
> damon_merge_two_regions() as well.
> 
> Signed-off-by: Suhaas Joshi <suhaas@s-joshi.in>
> ---
>  mm/damon/core.c             | 16 +++++++++++-----
>  mm/damon/tests/core-kunit.h | 20 ++++++++++++++++++--
>  2 files changed, 29 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index b63e60ef8990..fc202f90991b 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3524,20 +3524,26 @@ static void damon_verify_merge_two_regions(
>  /*
>   * Merge two adjacent regions into one region
>   */
> -static void damon_merge_two_regions(struct damon_target *t,
> -		struct damon_region *l, struct damon_region *r)
> +static void damon_merge_two_regions(struct damon_ctx *ctx,
> +				    struct damon_target *t,
> +				    struct damon_region *l,
> +				    struct damon_region *r)

Please use two tabs for indentation of the second and next lines of function
parameters.  For example:

'''
@@ -3739,8 +3739,9 @@ static noinline_for_stack void kdamond_apply_schemes(struct damon_ctx *c)
 }

 #ifdef CONFIG_DAMON_DEBUG_SANITY
-static void damon_verify_merge_two_regions(
-               struct damon_region *l, struct damon_region *r)
+static void damon_verify_merge_two_regions(struct damon_ctx *ctx,
+               struct damon_target *t, struct damon_region *l,
+               struct damon_region *r)
 {
        /* damon_merge_two_regions() may created incorrect left region */
        WARN_ONCE(l->ar.start >= l->ar.end, "l: %lu-%lu, r: %lu-%lu\n",
'''

>  {
>  	unsigned long sz_l = damon_sz_region(l), sz_r = damon_sz_region(r);
>  	int i;
> +	struct damon_probe *p;
>  
>  	l->nr_accesses = (l->nr_accesses * sz_l + r->nr_accesses * sz_r) /
>  			(sz_l + sz_r);
>  	l->age = (l->age * sz_l + r->age * sz_r) / (sz_l + sz_r);
>  	l->ar.end = r->ar.end;
> -	/* todo: do this for only installed probes */
> -	for (i = 0; i < DAMON_MAX_PROBES; i++)
> +
> +	i = 0;
> +	damon_for_each_probe(p, ctx) {
>  		l->probe_hits[i] = (l->probe_hits[i] * sz_l + r->probe_hits[i]
>  				* sz_r) / (sz_l + sz_r);
> +		++i;
> +	}
>  	damon_verify_merge_two_regions(l, r);
>  	damon_destroy_region(r, t);
>  }
> @@ -3590,7 +3596,7 @@ static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
>  			goto set_prev_continue;
>  		if (damon_sz_region(prev) + damon_sz_region(r) > sz_limit)
>  			goto set_prev_continue;
> -		damon_merge_two_regions(t, prev, r);
> +		damon_merge_two_regions(ctx, t, prev, r);
>  		continue;
>  set_prev_continue:
>  		prev = r;
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index ef146ca2ae8a..4e380c6c5eb2 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -182,13 +182,27 @@ static void damon_test_merge_two(struct kunit *test)
>  {
>  	struct damon_target *t;
>  	struct damon_region *r, *r2, *r3;
> +	struct damon_probe *p;
> +	struct damon_ctx *ctx;
>  	int i;
>  
> +	p = damon_new_probe();
> +	if (!p)
> +		kunit_skip(test, "probe alloc fail");
> +	ctx = damon_new_ctx();
> +	if (!ctx) {
> +		damon_destroy_probe(p);
> +		kunit_skip(test, "context alloc fail");
> +	}
> +	damon_add_probe(ctx, p);
>  	t = damon_new_target();
> -	if (!t)
> +	if (!t) {
> +		damon_destroy_ctx(ctx);
>  		kunit_skip(test, "target alloc fail");
> +	}
>  	r = damon_new_region(0, 100);
>  	if (!r) {
> +		damon_destroy_ctx(ctx);
>  		damon_free_target(t);
>  		kunit_skip(test, "region alloc fail");
>  	}
> @@ -198,6 +212,7 @@ static void damon_test_merge_two(struct kunit *test)
>  	damon_add_region(r, t);
>  	r2 = damon_new_region(100, 300);
>  	if (!r2) {
> +		damon_destroy_ctx(ctx);
>  		damon_free_target(t);
>  		kunit_skip(test, "second region alloc fail");
>  	}
> @@ -206,7 +221,7 @@ static void damon_test_merge_two(struct kunit *test)
>  	r2->age = 21;
>  	damon_add_region(r2, t);

Let's allocate and setup 'ctx' and 'p' here.  That will reduce alloc failure
handling code.  Also add 't' to 'ctx'.  That will let us to remove
damon_free_target() call from the final cleanup.

>  
> -	damon_merge_two_regions(t, r, r2);
> +	damon_merge_two_regions(ctx, t, r, r2);
>  	KUNIT_EXPECT_EQ(test, r->ar.start, 0ul);
>  	KUNIT_EXPECT_EQ(test, r->ar.end, 300ul);
>  	KUNIT_EXPECT_EQ(test, r->nr_accesses, 16u);
> @@ -220,6 +235,7 @@ static void damon_test_merge_two(struct kunit *test)
>  	}
>  	KUNIT_EXPECT_EQ(test, i, 1);
>  
> +	damon_destroy_ctx(ctx);
>  	damon_free_target(t);
>  }
>  
> -- 
> 2.55.0

Thanks,
SJ

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

* Re: [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions()
  2026-10-08 15:33   ` Suhaas Joshi
@ 2026-10-09  7:46     ` SJ Park
  0 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-10-09  7:46 UTC (permalink / raw)
  To: Suhaas Joshi; +Cc: SJ Park, akpm, aethernet65535, damon, linux-mm, linux-kernel

On Thu, 8 Oct 2026 21:03:15 +0530 Suhaas Joshi <suhaas@s-joshi.in> wrote:

> For some inexplicable reason, the cover-letter hasn't been sent again.
> 
> I am just adding the changelog here, in case the cover letter never arrives.
> 
> Changelog v1->v2:
> 
> 1. Simplified patch 1's commit message to make it clearer 
>    (Liew's suggestion)
> 2. Added comment docs for extra arguments I am adding to functions
>    (SJ's suggestion)
> 3. Destroyed the context in case r2 allocation fails in damon_test_merge_two()
>    (Sashiko/Liew/SJ suggestion)
> 4. Wrapped lines at 80 characters 
>    (SJ's suggestion)
> 
> As for why the cover-letter isn't being sent, I have no idea. Everything seems
> fine during `git send-email --dry-run`. Also seemed fine when I sent the series
> to myself as a test.
> Apologies for the inconvenience. I will make sure I fix this issue before sending
> v3 or any more series in the future.

No worries.  Thank you for clarifying this!  Maybe a possible workaround is
sending only cover letter first, confirming it is sent and appear on the
mailing list, and then sending patches using 'git send-email --in-reply-to'?


Thanks,
SJ

[...]

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

* Re: [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
  2026-10-09  2:40   ` kernel test robot
@ 2026-10-09  8:21     ` SJ Park
  2026-10-09 15:43       ` Suhaas Joshi
  0 siblings, 1 reply; 9+ messages in thread
From: SJ Park @ 2026-10-09  8:21 UTC (permalink / raw)
  To: kernel test robot
  Cc: SJ Park, Suhaas Joshi, akpm, aethernet65535, oe-kbuild-all,
	damon, linux-mm, linux-kernel

Hi Suhaas,

On Fri, 9 Oct 2026 10:40:07 +0800 kernel test robot <lkp@intel.com> wrote:

> Hi Suhaas,
> 
> kernel test robot noticed the following build errors:

Could you please check if this is a real problem of your patch?


Thanks,
SJ

[...]

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

* Re: [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at()
  2026-10-09  8:21     ` SJ Park
@ 2026-10-09 15:43       ` Suhaas Joshi
  0 siblings, 0 replies; 9+ messages in thread
From: Suhaas Joshi @ 2026-10-09 15:43 UTC (permalink / raw)
  To: SJ Park
  Cc: akpm, aethernet65535, oe-kbuild-all, damon, linux-mm, linux-kernel

On Fri, Oct 09, 2026 at 01:21:54AM -0700, SJ Park wrote:
> Hi Suhaas,
> 
> On Fri, 9 Oct 2026 10:40:07 +0800 kernel test robot <lkp@intel.com> wrote:
> 
> > Hi Suhaas,
> > 
> > kernel test robot noticed the following build errors:
> 
> Could you please check if this is a real problem of your patch?
> 
Hi SJ,

Yes, this seems to be a problem. Liew's patch [0] was merged recently,
after I started developing off mm-new. So I didn't catch this in my testing.

I will rebase, fix this up along with your other comments, and send out a v3
by tomorrow.

[0] https://lore.kernel.org/damon/20261006065209.41507-4-sj@kernel.org/

Thanks
Suhaas Joshi

> 
> Thanks,
> SJ
> 
> [...]

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

end of thread, other threads:[~2026-10-09 15:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20261008151944.113714-1-suhaas@s-joshi.in>
2026-10-08 15:19 ` [PATCH v2 1/2] mm/damon/core: Use only installed probe in damon_merge_two_regions() Suhaas Joshi
2026-10-08 15:33   ` Suhaas Joshi
2026-10-09  7:46     ` SJ Park
2026-10-09  7:43   ` SJ Park
2026-10-08 15:19 ` [PATCH v2 2/2] mm/damon/core: Copy only installed probe in damon_split_region_at() Suhaas Joshi
2026-10-09  2:40   ` kernel test robot
2026-10-09  8:21     ` SJ Park
2026-10-09 15:43       ` Suhaas Joshi
2026-10-09  4:06   ` kernel test robot

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

all inboxes | Powered by JetHome®