Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
Cc: SeongJae Park <sj@kernel.org>,
	damon@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: [RFC PATCH 03/14] samples/damon/mtier: replace damon_add_region() with damon_set_regions()
Date: Tue, 19 May 2026 23:28:35 -0700	[thread overview]
Message-ID: <20260520062858.167011-4-sj@kernel.org> (raw)
In-Reply-To: <20260520062858.167011-1-sj@kernel.org>

mtier DAMON sample module and DAMON virtual address operation set
(vaddr) unit tests are using damon_add_region() for setup of DAMON
monitoring target region boundaries setup.  But, damon_set_regions() is
designed for exactly the purpose.  All other DAMON API callers use the
function for the purpose.  Replace damon_add_region() usage in mtier
sample module with damon_set_regions(), for unifying the use case and
reducing the maintenance cost.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 samples/damon/mtier.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index 775838a23d935..eb1143de8df17 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -75,11 +75,11 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
 	struct damon_ctx *ctx;
 	struct damon_attrs attrs;
 	struct damon_target *target;
-	struct damon_region *region;
 	struct damos *scheme;
 	struct damos_quota_goal *quota_goal;
 	struct damos_filter *filter;
 	struct region_range addr;
+	struct damon_addr_range range;
 	int ret;
 
 	ctx = damon_new_ctx();
@@ -120,10 +120,12 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
 		addr.end = promote ? node1_end_addr : node0_end_addr;
 	}
 
-	region = damon_new_region(addr.start, addr.end);
-	if (!region)
+	range.start = addr.start;
+	range.end = addr.end;
+
+	ret = damon_set_regions(target, &range, 1, DAMON_MIN_REGION_SZ);
+	if (ret)
 		goto free_out;
-	damon_add_region(region, target);
 
 	scheme = damon_new_scheme(
 			/* access pattern */
-- 
2.47.3


  parent reply	other threads:[~2026-05-20  6:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  6:28 [RFC PATCH 00/14] mm/damon: minor improvements for code readability and tests SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 01/14] mm/damon/core: safely handle no region case in damon_set_regions() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 02/14] mm/damon/core: do not use region out of a loop " SeongJae Park
2026-05-20  6:28 ` SeongJae Park [this message]
2026-05-20  6:28 ` [RFC PATCH 04/14] mm/damon/tests/vaddr-kunit: replace damon_add_region() with damon_set_regions() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 05/14] mm/damon/core: hide damon_add_region() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 06/14] mm/damon/core: hide damon_insert_region() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 07/14] mm/damon/core: hide damon_destroy_region() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 08/14] mm/damon/core: add kdamond_call() debug_sanity check SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 09/14] mm/damon/core: remove damon_verify_nr_regions() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 10/14] mm/damon/tests/core-kunit: add damon_set_regions() test cases SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 11/14] selftests/damon/sysfs.py: stop kdamonds before failing SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 12/14] selftests/damon/sysfs.sh: test monitoring intervals goal dir SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 13/14] selftests/damon/sysfs.sh: test addr_unit file existence SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 14/14] selftests/damon/sysfs.sh: test pause " 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=20260520062858.167011-4-sj@kernel.org \
    --to=sj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox