Skip to contentSkip to conversation

mm-damon-core-add-kdamond_call-debug_sanity-check.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jun 2

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/damon/core: add kdamond_call() debug_sanity check
has been removed from the -mm tree. Its filename was
mm-damon-core-add-kdamond_call-debug_sanity-check.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: add kdamond_call() debug_sanity check
Date: Fri, 22 May 2026 08:40:19 -0700

kdamond_call() is the place where DAMON API callers are allowed to access the DAMON context's public internal state including the monitoring results. Hence it is important to ensure it is called with the expected DAMON context state. Do the check under DAMON_DEBUG_SANITY.

---

 mm/damon/core.c |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
mm/damon/core.c renamed from mm/damon/core.c~mm-damon-core-add-kdamond_call-debug_sanity-check +33 -0
@@ -3329,6 +3329,37 @@ static void kdamond_usleep(unsigned long
 		usleep_range_idle(usecs, usecs + 1);
 }
 
+#ifdef CONFIG_DAMON_DEBUG_SANITY
+static void damon_verify_ctx(struct damon_ctx *c)
+{
+	struct damon_target *t;
+	struct damon_region *r;
+
+	damon_for_each_target(t, c) {
+		struct damon_region *prev_r = NULL;
+		unsigned int nr_regions = 0;
+
+		damon_for_each_region(r, t) {
+			WARN_ONCE(r->ar.start >= r->ar.end,
+					"region start (%lu) >= end (%lu)\n",
+					r->ar.start, r->ar.end);
+			WARN_ONCE(prev_r && prev_r->ar.end > r->ar.start,
+					"region overlap (%lu > %lu)\n",
+					prev_r->ar.end, r->ar.start);
+			prev_r = r;
+			nr_regions++;
+		}
+		WARN_ONCE(damon_nr_regions(t) != nr_regions,
+				"nr_regions mismatch: %u != %u\n",
+				damon_nr_regions(t), nr_regions);
+	}
+}
+#else
+static void damon_verify_ctx(struct damon_ctx *c)
+{
+}
+#endif
+
 /*
  * kdamond_call() - handle damon_call_control objects.
  * @ctx:	The &struct damon_ctx of the kdamond.
@@ -3344,6 +3375,8 @@ static void kdamond_call(struct damon_ct
 	struct damon_call_control *control, *next;
 	LIST_HEAD(controls);
 
+	damon_verify_ctx(ctx);
+
 	mutex_lock(&ctx->call_controls_lock);
 	list_splice_tail_init(&ctx->call_controls, &controls);
 	mutex_unlock(&ctx->call_controls_lock);

_

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

mm-damon-reclaim-handle-ctx-allocation-failure.patch mm-damonn-lru_sort-handle-ctx-allocation-failure.patch maintainers-add-testing-abi-documents-for-mm.patch