All of lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: [PATCH 07/10] mm/damon/core: add damon_split_region_at() debug_sanity check
Date: Fri,  6 Mar 2026 07:29:10 -0800	[thread overview]
Message-ID: <20260306152914.86303-8-sj@kernel.org> (raw)
In-Reply-To: <20260306152914.86303-1-sj@kernel.org>

damon_split_region_at() should be called with the correct address to
split on.  Add a sanity check for that under CONFIG_DAMON_DEBUG_SANITY.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 93d1577b1ae07..be2300cf3aeae 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2586,6 +2586,21 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
 			threshold / 2 < max_thres);
 }
 
+#ifdef CONFIG_DAMON_DEBUG_SANITY
+static void damon_verify_split_region_at(struct damon_region *r,
+		unsigned long sz_r)
+{
+	WARN_ONCE(sz_r == 0 || sz_r >= damon_sz_region(r),
+			"sz_r: %lu r: %lu-%lu (%lu)\n",
+			sz_r, r->ar.start, r->ar.end, damon_sz_region(r));
+}
+#else
+static void damon_verify_split_region_at(struct damon_region *r,
+		unsigned long sz_r)
+{
+}
+#endif
+
 /*
  * Split a region in two
  *
@@ -2597,6 +2612,7 @@ static void damon_split_region_at(struct damon_target *t,
 {
 	struct damon_region *new;
 
+	damon_verify_split_region_at(r, sz_r);
 	new = damon_new_region(r->ar.start + sz_r, r->ar.end);
 	if (!new)
 		return;
-- 
2.47.3

  parent reply	other threads:[~2026-03-06 15:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 15:29 [PATCH 00/10] mm/damon: add optional debugging-purpose sanity checks SeongJae Park
2026-03-06 15:29 ` [PATCH 01/10] mm/damon: add CONFIG_DAMON_DEBUG_SANITY SeongJae Park
2026-03-06 15:29 ` [PATCH 02/10] mm/damon/core: add damon_new_region() debug_sanity check SeongJae Park
2026-03-06 15:29 ` [PATCH 03/10] mm/damon/core: add damon_del_region() " SeongJae Park
2026-03-06 15:29 ` [PATCH 04/10] mm/damon/core: add damon_nr_regions() " SeongJae Park
2026-03-06 15:29 ` [PATCH 05/10] mm/damon/core: add damon_merge_two_regions() " SeongJae Park
2026-03-06 15:29 ` [PATCH 06/10] mm/damon/core: add damon_merge_regions_of() " SeongJae Park
2026-03-06 15:29 ` SeongJae Park [this message]
2026-03-06 15:29 ` [PATCH 08/10] mm/damon/core: add damon_reset_aggregated() " SeongJae Park
2026-03-06 15:29 ` [PATCH 09/10] mm/damon/tests/.kunitconifg: enable DAMON_DEBUG_SANITY SeongJae Park
2026-03-06 15:29 ` [PATCH 10/10] selftests/damon/config: " SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260306152914.86303-8-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.