All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling
@ 2026-11-23  4:26 Eva Kurchatova
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions Eva Kurchatova
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-23  4:26 UTC (permalink / raw)
  To: khorenko, vladimir.riabchun; +Cc: devel

Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-156361

SJ Park (1):
  ms/mm/damon/core: handle region split failure in
    apply_min_nr_regions()

SeongJae Park (2):
  ms/mm/damon/core: split regions for min_nr_regions
  ms/mm/damon/vaddr: do not split regions for min_nr_regions

 mm/damon/core.c              | 51 ++++++++++++++++++++++----
 mm/damon/tests/vaddr-kunit.h | 60 -------------------------------
 mm/damon/vaddr.c             | 70 ++----------------------------------
 3 files changed, 46 insertions(+), 135 deletions(-)

-- 
2.56.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions
  2026-11-23  4:26 [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Eva Kurchatova
@ 2026-11-23  4:26 ` Eva Kurchatova
  2026-11-23  4:32   ` no-reply
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 2/3] ms/mm/damon/vaddr: do not " Eva Kurchatova
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-23  4:26 UTC (permalink / raw)
  To: khorenko, vladimir.riabchun; +Cc: devel

From: SeongJae Park <sj@kernel.org>

Patch series "mm/damon: strictly respect min_nr_regions".

DAMON core respects min_nr_regions only at merge operation.  DAMON API
callers are therefore responsible to respect or ignore that.  Only vaddr
ops is respecting that, but only for initial start time.  DAMON sysfs
interface allows users to setup the initial regions that DAMON core also
respects.  But, again, it works for only the initial time.  Users setting
the regions for min_nr_regions can be difficult and inefficient, when the
min_nr_regions value is high.  There was actually a report [1] from a
user.  The use case was page granular access monitoring with a large
aggregation interval.

Make the following three changes for resolving the issue.  First (patch
1), make DAMON core split regions at the beginning and every aggregation
interval, to respect the min_nr_regions.  Second (patch 2), drop the
vaddr's split operations and related code that are no more needed.  Third
(patch 3), add a kunit test for the newly introduced function.

This patch (of 3):

DAMON core layer respects the min_nr_regions parameter by setting the
maximum size of each region as total monitoring region size divided by the
parameter value.  And the limit is applied by preventing merge of regions
that result in a region larger than the maximum size.  The limit is
updated per ops update interval, because vaddr updates the monitoring
regions on the ops update callback.

It does nothing for the beginning state.  That's because the users can set
the initial monitoring regions as they want.  That is, if the users really
care about the min_nr_regions, they are supposed to set the initial
monitoring regions to have more than min_nr_regions regions.  The virtual
address space operation set, vaddr, has an exceptional case.  Users can
ask the ops set to configure the initial regions on its own.  For the
case, vaddr sets up the initial regions to meet the min_nr_regions.  So,
vaddr has exceptional support, but basically users are required to set the
regions on their own if they want min_nr_regions to be respected.

When 'min_nr_regions' is high, such initial setup is difficult.  If DAMON
sysfs interface is used for that, the memory for saving the initial setup
is also a waste.

Even if the user forgives the setup, DAMON will eventually make more than
min_nr_regions regions by splitting operations.  But it will take time.
If the aggregation interval is long, the delay could be problematic.
There was actually a report [1] of the case.  The reporter wanted to do
page granular monitoring with a large aggregation interval.

Also, DAMON is doing nothing for online changes on monitoring regions and
min_nr_regions.  For example, the user can remove a monitoring region or
increase min_nr_regions while DAMON is running.

Split regions larger than the size at the beginning of the kdamond main
loop, to fix the initial setup issue.  Also do the split every aggregation
interval, for online changes.  This means the behavior is slightly
changed.  It is difficult to imagine a use case that actually depends on
the old behavior, though.  So this change is arguably fine.

Note that the size limit is aligned by damon_ctx->min_region_sz and cannot
be zero.  That is, if min_nr_region is larger than the total size of
monitoring regions divided by ->min_region_sz, that cannot be respected.

Link: https://lkml.kernel.org/r/20260228222831.7232-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20260228222831.7232-2-sj@kernel.org
Link: https://lore.kernel.org/CAC5umyjmJE9SBqjbetZZecpY54bHpn2AvCGNv3aF6J=1cfoPXQ@mail.gmail.com [1]
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit b1029f29eb1d5fbf07fa8db9b5e7ab6d9813ad67)

Rebase note: this tree has no per-context min_region_sz, so the size
limit is aligned to DAMON_MIN_REGION. kdamond_fn() here still calls the
after_aggregation callback after the merge, and the regions are split
between the two, as mainline splits them before kdamond_call().

https://virtuozzo.atlassian.net/browse/VSTOR-156361
Feature: fix ms/mm

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 mm/damon/core.c | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 0776452a1abb..aa1aa45264a7 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1047,6 +1047,40 @@ static unsigned long damon_region_sz_limit(struct damon_ctx *ctx)
 	return sz;
 }
 
+static void damon_split_region_at(struct damon_target *t,
+				  struct damon_region *r, unsigned long sz_r);
+
+/*
+ * damon_apply_min_nr_regions() - Make effect of min_nr_regions parameter.
+ * @ctx:	monitoring context.
+ *
+ * This function implement min_nr_regions (minimum number of damon_region
+ * objects in the given monitoring context) behavior.  It first calculates
+ * maximum size of each region for enforcing the min_nr_regions as total size
+ * of the regions divided by the min_nr_regions.  After that, this function
+ * splits regions to ensure all regions are equal to or smaller than the size
+ * limit.  Finally, this function returns the maximum size limit.
+ *
+ * Returns: maximum size of each region for convincing min_nr_regions.
+ */
+static unsigned long damon_apply_min_nr_regions(struct damon_ctx *ctx)
+{
+	unsigned long max_region_sz = damon_region_sz_limit(ctx);
+	struct damon_target *t;
+	struct damon_region *r, *next;
+
+	max_region_sz = ALIGN(max_region_sz, DAMON_MIN_REGION);
+	damon_for_each_target(t, ctx) {
+		damon_for_each_region_safe(r, next, t) {
+			while (damon_sz_region(r) > max_region_sz) {
+				damon_split_region_at(t, r, max_region_sz);
+				r = damon_next_region(r);
+			}
+		}
+	}
+	return max_region_sz;
+}
+
 static int kdamond_fn(void *data);
 
 /*
@@ -1182,9 +1216,6 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
 	}
 }
 
-static void damon_split_region_at(struct damon_target *t,
-				  struct damon_region *r, unsigned long sz_r);
-
 static bool __damos_valid_target(struct damon_region *r, struct damos *s)
 {
 	unsigned long sz;
@@ -1992,7 +2023,7 @@ static int kdamond_fn(void *data)
 	if (!ctx->regions_score_histogram)
 		goto done;
 
-	sz_limit = damon_region_sz_limit(ctx);
+	sz_limit = damon_apply_min_nr_regions(ctx);
 
 	while (!kdamond_need_stop(ctx)) {
 		/*
@@ -2025,6 +2056,8 @@ static int kdamond_fn(void *data)
 			kdamond_merge_regions(ctx,
 					max_nr_accesses / 10,
 					sz_limit);
+			/* online updates might be made */
+			sz_limit = damon_apply_min_nr_regions(ctx);
 			if (ctx->callback.after_aggregation &&
 					ctx->callback.after_aggregation(ctx))
 				break;
@@ -2055,7 +2088,6 @@ static int kdamond_fn(void *data)
 				sample_interval;
 			if (ctx->ops.update)
 				ctx->ops.update(ctx);
-			sz_limit = damon_region_sz_limit(ctx);
 		}
 	}
 done:
-- 
2.56.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* [Devel] [PATCH hci-8.2 2/3] ms/mm/damon/vaddr: do not split regions for min_nr_regions
  2026-11-23  4:26 [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Eva Kurchatova
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions Eva Kurchatova
@ 2026-11-23  4:26 ` Eva Kurchatova
  2026-11-23  4:32   ` no-reply
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions() Eva Kurchatova
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-23  4:26 UTC (permalink / raw)
  To: khorenko, vladimir.riabchun; +Cc: devel

From: SeongJae Park <sj@kernel.org>

The previous commit made DAMON core split regions at the beginning for
min_nr_regions.  The virtual address space operation set (vaddr) does
similar work on its own, for a case user delegates entire initial
monitoring regions setup to vaddr.  It is unnecessary now, as DAMON core
will do similar work for any case.  Remove the duplicated work in vaddr.

Also, remove a helper function that was being used only for the work, and
the test code of the helper function.

Link: https://lkml.kernel.org/r/20260228222831.7232-3-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 442d87c7db9e9e2a569a49d38f404b8b556b8719)

Rebase note: damon_set_regions() takes no minimum region size in this
tree, it aligns the ranges to DAMON_MIN_REGION itself.

https://virtuozzo.atlassian.net/browse/VSTOR-156361
Feature: fix ms/mm

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 mm/damon/tests/vaddr-kunit.h | 60 -------------------------------
 mm/damon/vaddr.c             | 70 ++----------------------------------
 2 files changed, 2 insertions(+), 128 deletions(-)

diff --git a/mm/damon/tests/vaddr-kunit.h b/mm/damon/tests/vaddr-kunit.h
index b9fe3bc8472b..1b48a19bd324 100644
--- a/mm/damon/tests/vaddr-kunit.h
+++ b/mm/damon/tests/vaddr-kunit.h
@@ -246,72 +246,12 @@ static void damon_test_apply_three_regions4(struct kunit *test)
 			new_three_regions, expected, ARRAY_SIZE(expected));
 }
 
-static void damon_test_split_evenly_fail(struct kunit *test,
-		unsigned long start, unsigned long end, unsigned int nr_pieces)
-{
-	struct damon_target *t = damon_new_target();
-	struct damon_region *r = damon_new_region(start, end);
-
-	damon_add_region(r, t);
-	KUNIT_EXPECT_EQ(test,
-			damon_va_evenly_split_region(t, r, nr_pieces), -EINVAL);
-	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 1u);
-
-	damon_for_each_region(r, t) {
-		KUNIT_EXPECT_EQ(test, r->ar.start, start);
-		KUNIT_EXPECT_EQ(test, r->ar.end, end);
-	}
-
-	damon_free_target(t);
-}
-
-static void damon_test_split_evenly_succ(struct kunit *test,
-	unsigned long start, unsigned long end, unsigned int nr_pieces)
-{
-	struct damon_target *t = damon_new_target();
-	struct damon_region *r = damon_new_region(start, end);
-	unsigned long expected_width = (end - start) / nr_pieces;
-	unsigned long i = 0;
-
-	damon_add_region(r, t);
-	KUNIT_EXPECT_EQ(test,
-			damon_va_evenly_split_region(t, r, nr_pieces), 0);
-	KUNIT_EXPECT_EQ(test, damon_nr_regions(t), nr_pieces);
-
-	damon_for_each_region(r, t) {
-		if (i == nr_pieces - 1) {
-			KUNIT_EXPECT_EQ(test,
-				r->ar.start, start + i * expected_width);
-			KUNIT_EXPECT_EQ(test, r->ar.end, end);
-			break;
-		}
-		KUNIT_EXPECT_EQ(test,
-				r->ar.start, start + i++ * expected_width);
-		KUNIT_EXPECT_EQ(test, r->ar.end, start + i * expected_width);
-	}
-	damon_free_target(t);
-}
-
-static void damon_test_split_evenly(struct kunit *test)
-{
-	KUNIT_EXPECT_EQ(test, damon_va_evenly_split_region(NULL, NULL, 5),
-			-EINVAL);
-
-	damon_test_split_evenly_fail(test, 0, 100, 0);
-	damon_test_split_evenly_succ(test, 0, 100, 10);
-	damon_test_split_evenly_succ(test, 5, 59, 5);
-	damon_test_split_evenly_succ(test, 4, 6, 1);
-	damon_test_split_evenly_succ(test, 0, 3, 2);
-	damon_test_split_evenly_fail(test, 5, 6, 2);
-}
-
 static struct kunit_case damon_test_cases[] = {
 	KUNIT_CASE(damon_test_three_regions_in_vmas),
 	KUNIT_CASE(damon_test_apply_three_regions1),
 	KUNIT_CASE(damon_test_apply_three_regions2),
 	KUNIT_CASE(damon_test_apply_three_regions3),
 	KUNIT_CASE(damon_test_apply_three_regions4),
-	KUNIT_CASE(damon_test_split_evenly),
 	{},
 };
 
diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c
index b9eaa20b73b9..a01d138fbc4f 100644
--- a/mm/damon/vaddr.c
+++ b/mm/damon/vaddr.c
@@ -52,52 +52,6 @@ static struct mm_struct *damon_get_mm(struct damon_target *t)
 	return mm;
 }
 
-/*
- * Functions for the initial monitoring target regions construction
- */
-
-/*
- * Size-evenly split a region into 'nr_pieces' small regions
- *
- * Returns 0 on success, or negative error code otherwise.
- */
-static int damon_va_evenly_split_region(struct damon_target *t,
-		struct damon_region *r, unsigned int nr_pieces)
-{
-	unsigned long sz_orig, sz_piece, orig_end;
-	struct damon_region *n = NULL, *next;
-	unsigned long start;
-	unsigned int i;
-
-	if (!r || !nr_pieces)
-		return -EINVAL;
-
-	if (nr_pieces == 1)
-		return 0;
-
-	orig_end = r->ar.end;
-	sz_orig = damon_sz_region(r);
-	sz_piece = ALIGN_DOWN(sz_orig / nr_pieces, DAMON_MIN_REGION);
-
-	if (!sz_piece)
-		return -EINVAL;
-
-	r->ar.end = r->ar.start + sz_piece;
-	next = damon_next_region(r);
-	for (start = r->ar.end, i = 1; i < nr_pieces; start += sz_piece, i++) {
-		n = damon_new_region(start, start + sz_piece);
-		if (!n)
-			return -ENOMEM;
-		damon_insert_region(n, r, next, t);
-		r = n;
-	}
-	/* complement last region for possible rounding error */
-	if (n)
-		n->ar.end = orig_end;
-
-	return 0;
-}
-
 static unsigned long sz_range(struct damon_addr_range *r)
 {
 	return r->end - r->start;
@@ -239,10 +193,8 @@ static void __damon_va_init_regions(struct damon_ctx *ctx,
 				     struct damon_target *t)
 {
 	struct damon_target *ti;
-	struct damon_region *r;
 	struct damon_addr_range regions[3];
-	unsigned long sz = 0, nr_pieces;
-	int i, tidx = 0;
+	int tidx = 0;
 
 	if (damon_va_three_regions(t, regions)) {
 		damon_for_each_target(ti, ctx) {
@@ -254,25 +206,7 @@ static void __damon_va_init_regions(struct damon_ctx *ctx,
 		return;
 	}
 
-	for (i = 0; i < 3; i++)
-		sz += regions[i].end - regions[i].start;
-	if (ctx->attrs.min_nr_regions)
-		sz /= ctx->attrs.min_nr_regions;
-	if (sz < DAMON_MIN_REGION)
-		sz = DAMON_MIN_REGION;
-
-	/* Set the initial three regions of the target */
-	for (i = 0; i < 3; i++) {
-		r = damon_new_region(regions[i].start, regions[i].end);
-		if (!r) {
-			pr_err("%d'th init region creation failed\n", i);
-			return;
-		}
-		damon_add_region(r, t);
-
-		nr_pieces = (regions[i].end - regions[i].start) / sz;
-		damon_va_evenly_split_region(t, r, nr_pieces);
-	}
+	damon_set_regions(t, regions, 3);
 }
 
 /* Initialize '->regions_list' of every target (task) */
-- 
2.56.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* [Devel] [PATCH hci-8.2 3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions()
  2026-11-23  4:26 [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Eva Kurchatova
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions Eva Kurchatova
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 2/3] ms/mm/damon/vaddr: do not " Eva Kurchatova
@ 2026-11-23  4:26 ` Eva Kurchatova
  2026-11-23  4:35   ` no-reply
  2026-11-30 15:47 ` [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Konstantin Khorenko
  2026-11-30 15:48 ` Konstantin Khorenko
  4 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-23  4:26 UTC (permalink / raw)
  To: khorenko, vladimir.riabchun; +Cc: devel

From: SJ Park <sj@kernel.org>

damon_apply_min_nr_regions() repeatedly split each region until its size
becomes small enough to meet the user-defined low limit of the number of
regions.  The loop assumes the split operation (damon_split_region_at())
will always succeed and create the new region.  But the operation could
silently fail for memory allocation failures, for example.

If such failure happens and the region was the last region, the linked
list-based next region fetching returns invalid pointer.  As a result,
invalid memory dereference and corruption could happen.  Even if the
corner case is handled, it imposes stress to the allocator by trying split
regions for other targets.  Fix the issue by breaking all the loops for
any region split failure.

This means there could be a min_nr_regions violation.  It will only rarely
happen since the allocation is arguably too small to fail.  Even if it
happens, it is only temporal.  damon_apply_min_nr_regions() will be called
again after the aggregation interval.

The user impact of the issue should be minor, since the allocation is
arguably too small to fail.  But, it could still theoretically happen, and
the consequence is very bad.

This issue was discovered [1] by Sashiko.

Link: https://lore.kernel.org/20260719155442.88794-1-sj@kernel.org
Link: https://lore.kernel.org/20260717011834.120715-1-sj@kernel.org [1]
Fixes: b1029f29eb1d ("mm/damon/core: split regions for min_nr_regions")
Signed-off-by: SJ Park <sj@kernel.org>
Cc: <stable@vger.kernel.org> # 7.1.x
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit c608748607620f331196ed0ba9fe4017892c1457)

https://virtuozzo.atlassian.net/browse/VSTOR-156361
Feature: fix ms/mm

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 mm/damon/core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index aa1aa45264a7..9a11de9b948b 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1047,7 +1047,7 @@ static unsigned long damon_region_sz_limit(struct damon_ctx *ctx)
 	return sz;
 }
 
-static void damon_split_region_at(struct damon_target *t,
+static int damon_split_region_at(struct damon_target *t,
 				  struct damon_region *r, unsigned long sz_r);
 
 /*
@@ -1073,11 +1073,13 @@ 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) {
-				damon_split_region_at(t, r, max_region_sz);
+				if (damon_split_region_at(t, r, max_region_sz))
+					goto out;
 				r = damon_next_region(r);
 			}
 		}
 	}
+out:
 	return max_region_sz;
 }
 
@@ -1788,15 +1790,17 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
  *
  * 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 void damon_split_region_at(struct damon_target *t,
+static int damon_split_region_at(struct damon_target *t,
 				  struct damon_region *r, unsigned long sz_r)
 {
 	struct damon_region *new;
 
 	new = damon_new_region(r->ar.start + sz_r, r->ar.end);
 	if (!new)
-		return;
+		return -ENOMEM;
 
 	r->ar.end = new->ar.start;
 
@@ -1806,6 +1810,7 @@ static void damon_split_region_at(struct damon_target *t,
 	new->nr_accesses = r->nr_accesses;
 
 	damon_insert_region(new, r, damon_next_region(r), t);
+	return 0;
 }
 
 /* Split every region in the given target into 'nr_subs' regions */
-- 
2.56.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions Eva Kurchatova
@ 2026-11-23  4:32   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-23  4:32 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko, vladimir.riabchun; +Cc: devel

> From: SeongJae Park <sj@kernel.org>
> 
> Patch series "mm/damon: strictly respect min_nr_regions".
> 
> DAMON core respects min_nr_regions only at merge operation.  DAMON API
> callers are therefore responsible to respect or ignore that.  Only vaddr
> ops is respecting that, but only for initial start time.  DAMON sysfs
> interface allows users to setup the initial regions that DAMON core also
> respects.  But, again, it works for only the initial time.  Users setting
> the regions for min_nr_regions can be difficult and inefficient, when the
> min_nr_regions value is high.  There was actually a report [1] from a
> user.  The use case was page granular access monitoring with a large
> aggregation interval.
> 
> Make the following three changes for resolving the issue.  First (patch
> [ ... ]
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-156361
> Feature: fix ms/mm
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261123042846.1684796-1-eva.kurchatova@virtuozzo.com?part=1


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2 2/3] ms/mm/damon/vaddr: do not split regions for min_nr_regions
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 2/3] ms/mm/damon/vaddr: do not " Eva Kurchatova
@ 2026-11-23  4:32   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-23  4:32 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko, vladimir.riabchun; +Cc: devel

> From: SeongJae Park <sj@kernel.org>
> 
> The previous commit made DAMON core split regions at the beginning for
> min_nr_regions.  The virtual address space operation set (vaddr) does
> similar work on its own, for a case user delegates entire initial
> monitoring regions setup to vaddr.  It is unnecessary now, as DAMON core
> will do similar work for any case.  Remove the duplicated work in vaddr.
> 
> Also, remove a helper function that was being used only for the work, and
> the test code of the helper function.
> 
> Link: https://lkml.kernel.org/r/20260228222831.7232-3-sj@kernel.org
> Signed-off-by: SeongJae Park <sj@kernel.org>
> Cc: Brendan Higgins <brendan.higgins@linux.dev>
> Cc: David Gow <davidgow@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit 442d87c7db9e9e2a569a49d38f404b8b556b8719)
> 
> Rebase note: damon_set_regions() takes no minimum region size in this
> tree, it aligns the ranges to DAMON_MIN_REGION itself.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-156361
> Feature: fix ms/mm
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261123042846.1684796-1-eva.kurchatova@virtuozzo.com?part=2


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2 3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions()
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions() Eva Kurchatova
@ 2026-11-23  4:35   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-23  4:35 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko, vladimir.riabchun; +Cc: devel

> From: SJ Park <sj@kernel.org>
> 
> damon_apply_min_nr_regions() repeatedly split each region until its size
> becomes small enough to meet the user-defined low limit of the number of
> regions.  The loop assumes the split operation (damon_split_region_at())
> will always succeed and create the new region.  But the operation could
> silently fail for memory allocation failures, for example.
> 
> If such failure happens and the region was the last region, the linked
> list-based next region fetching returns invalid pointer.  As a result,
> invalid memory dereference and corruption could happen.  Even if the
> corner case is handled, it imposes stress to the allocator by trying split
> regions for other targets.  Fix the issue by breaking all the loops for
> any region split failure.
> 
> [ ... ]
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-156361
> Feature: fix ms/mm
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

Sashiko has reviewed this patch and found no issues.

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261123042846.1684796-1-eva.kurchatova@virtuozzo.com?part=3


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling
  2026-11-23  4:26 [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Eva Kurchatova
                   ` (2 preceding siblings ...)
  2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions() Eva Kurchatova
@ 2026-11-30 15:47 ` Konstantin Khorenko
  2026-11-30 15:48 ` Konstantin Khorenko
  4 siblings, 0 replies; 9+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 15:47 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying as is.

All three are faithful backports of b1029f29eb1d5, 442d87c7db9e9 and
c608748607620, the rebase notes cover every difference, and leaving
out the upstream kunit patch ca6969e074dc1 is right, it needs
ctx->min_region_sz that this tree does not have.

On Mon, 23 Nov 2026 06:26:37 +0200, Eva Kurchatova wrote:

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

* Re: [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling
  2026-11-23  4:26 [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Eva Kurchatova
                   ` (3 preceding siblings ...)
  2026-11-30 15:47 ` [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Konstantin Khorenko
@ 2026-11-30 15:48 ` Konstantin Khorenko
  4 siblings, 0 replies; 9+ messages in thread
From: Konstantin Khorenko @ 2026-11-30 15:48 UTC (permalink / raw)
  To: vladimir.riabchun, Eva Kurchatova; +Cc: devel

On Mon, 23 Nov 2026 06:26:37 +0200, Eva Kurchatova wrote:
> ms/damon: fix DAMON region split handling
> 
> Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-156361
> 
> SJ Park (1):
>   ms/mm/damon/core: handle region split failure in
>     apply_min_nr_regions()
> 
> [...]

Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.26.6.vz10, thanks!

[1/3] ms/mm/damon/core: split regions for min_nr_regions
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/46e3a2f4fe84
[2/3] ms/mm/damon/vaddr: do not split regions for min_nr_regions
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/05d51d5caf9f
[3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions()
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/1aa23c2bff5c

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

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

end of thread, other threads:[~2026-11-30 15:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23  4:26 [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Eva Kurchatova
2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 1/3] ms/mm/damon/core: split regions for min_nr_regions Eva Kurchatova
2026-11-23  4:32   ` no-reply
2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 2/3] ms/mm/damon/vaddr: do not " Eva Kurchatova
2026-11-23  4:32   ` no-reply
2026-11-23  4:26 ` [Devel] [PATCH hci-8.2 3/3] ms/mm/damon/core: handle region split failure in apply_min_nr_regions() Eva Kurchatova
2026-11-23  4:35   ` no-reply
2026-11-30 15:47 ` [Devel] [PATCH hci-8.2 0/3] ms/damon: fix DAMON region split handling Konstantin Khorenko
2026-11-30 15:48 ` Konstantin Khorenko

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.