Skip to contentSkip to conversation

mm-damon-core-avoid-holes-in-newly-set-monitoring-target-ranges.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Oct 3, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/damon/core: avoid holes in newly set monitoring target ranges
has been removed from the -mm tree. Its filename was
mm-damon-core-avoid-holes-in-newly-set-monitoring-target-ranges.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: SeongJae Park <[email protected]>
Subject: mm/damon/core: avoid holes in newly set monitoring target ranges
Date: Fri, 9 Sep 2022 20:28:56 +0000

When there are two or more non-contiguous regions intersecting with given new ranges, 'damon_set_regions()' does not fill the holes. This commit makes the function to fill the holes with newly created regions.

[[email protected]: handle error from 'damon_fill_regions_holes()']
Fixes 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces")
Cc Brendan Higgins <[email protected]>
Cc Jonathan Corbet <[email protected]>
Cc Shuah Khan <[email protected]>

---

 mm/damon/core.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
mm/damon/core.c renamed from mm/damon/core.c~mm-damon-core-avoid-holes-in-newly-set-monitoring-target-ranges +30 -0
@@ -169,6 +169,30 @@ static bool damon_intersect(struct damon
 }
 
 /*
+ * Fill holes in regions with new regions.
+ */
+static int damon_fill_regions_holes(struct damon_region *first,
+		struct damon_region *last, struct damon_target *t)
+{
+	struct damon_region *r = first;
+
+	damon_for_each_region_from(r, t) {
+		struct damon_region *next, *newr;
+
+		if (r == last)
+			break;
+		next = damon_next_region(r);
+		if (r->ar.end != next->ar.start) {
+			newr = damon_new_region(r->ar.end, next->ar.start);
+			if (!newr)
+				return -ENOMEM;
+			damon_insert_region(newr, r, next, t);
+		}
+	}
+	return 0;
+}
+
+/*
  * damon_set_regions() - Set regions of a target for given address ranges.
  * @t:		the given target.
  * @ranges:	array of new monitoring target ranges.
@@ -184,6 +208,7 @@ int damon_set_regions(struct damon_targe
 {
 	struct damon_region *r, *next;
 	unsigned int i;
+	int err;
 
 	/* Remove regions which are not in the new ranges */
 	damon_for_each_region_safe(r, next, t) {
@@ -226,6 +251,11 @@ int damon_set_regions(struct damon_targe
 			first->ar.start = ALIGN_DOWN(range->start,
 					DAMON_MIN_REGION);
 			last->ar.end = ALIGN(range->end, DAMON_MIN_REGION);
+
+			/* fill possible holes in the range */
+			err = damon_fill_regions_holes(first, last, t);
+			if (err)
+				return err;
 		}
 	}
 	return 0;

_

Patches currently in -mm which might be from [email protected] are

mm-damon-core-initialize-damon_target-list-in-damon_new_target.patch