Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] samples/damon/mtier: use damon_addr_range consistently
@ 2026-07-20 13:06 Enze Li
  2026-07-21  1:28 ` SJ Park
  0 siblings, 1 reply; 3+ messages in thread
From: Enze Li @ 2026-07-20 13:06 UTC (permalink / raw)
  To: sj; +Cc: damon, linux-mm, linux-kernel, enze.li, Enze Li

The DAMON provides struct damon_addr_range for unified address range
management.  However, the mtier sample still defines a local struct
region_range and mixes its usage with struct damon_addr_range in
damon_sample_mtier_build_ctx().

This patch removes the local struct region_range and changes the
parameter type of nid_to_phys() to struct damon_addr_range.  It also
gets rid of the now-redundant local variable and pass the address range
directly to damon_set_regions().

Signed-off-by: Enze Li <lienze@kylinos.cn>
---
v2:
- Fix inaccurate "identical layout" claim in commit message
- Remove redundant range variable and pass &addr directly to
  damon_set_regions()

 samples/damon/mtier.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index ac9c24b92ead..3712287f009c 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -52,12 +52,7 @@ module_param(detect_node_addresses, bool, 0600);
 
 static struct damon_ctx *ctxs[2];
 
-struct region_range {
-	phys_addr_t start;
-	phys_addr_t end;
-};
-
-static int nid_to_phys(int target_node, struct region_range *range)
+static int nid_to_phys(int target_node, struct damon_addr_range *range)
 {
 	if (!node_online(target_node)) {
 		pr_err("NUMA node %d is not online\n", target_node);
@@ -78,8 +73,7 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
 	struct damos *scheme;
 	struct damos_quota_goal *quota_goal;
 	struct damos_filter *filter;
-	struct region_range addr;
-	struct damon_addr_range range;
+	struct damon_addr_range addr;
 	int ret;
 
 	ctx = damon_new_ctx();
@@ -123,10 +117,7 @@ static struct damon_ctx *damon_sample_mtier_build_ctx(bool promote)
 	if (addr.start >= addr.end)
 		goto free_out;
 
-	range.start = addr.start;
-	range.end = addr.end;
-
-	ret = damon_set_regions(target, &range, 1, DAMON_MIN_REGION_SZ);
+	ret = damon_set_regions(target, &addr, 1, DAMON_MIN_REGION_SZ);
 	if (ret)
 		goto free_out;
 

base-commit: c872b70f5d6c742ad34b8e838c92af81c8920b3e
-- 
2.43.0



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

* Re: [PATCH v2] samples/damon/mtier: use damon_addr_range consistently
  2026-07-20 13:06 [PATCH v2] samples/damon/mtier: use damon_addr_range consistently Enze Li
@ 2026-07-21  1:28 ` SJ Park
  2026-07-21  6:33   ` Enze Li
  0 siblings, 1 reply; 3+ messages in thread
From: SJ Park @ 2026-07-21  1:28 UTC (permalink / raw)
  To: Enze Li; +Cc: SJ Park, damon, linux-mm, linux-kernel, enze.li

Hello Enze,

On Mon, 20 Jul 2026 21:06:42 +0800 Enze Li <lienze@kylinos.cn> wrote:

> The DAMON provides struct damon_addr_range for unified address range
> management.  However, the mtier sample still defines a local struct
> region_range and mixes its usage with struct damon_addr_range in
> damon_sample_mtier_build_ctx().

damon_addr_range is for DAMON core layer address system that uses 'unsigned
long' as the address type.  Because 'mtier' is dealing directly with physical
address, we use a dedicated struct for that purpose.  On 32bit systems having
more than 4 GiB memory, this may be necessary.

'mtier' doesn't really take care of the >4GiB 32bit system since it is simply
casting the 'phys_addr_t' addresses into 'unsigned long' addresses.  But it
might support it better in future, using the addr_unit parameter.

> 
> This patch removes the local struct region_range and changes the
> parameter type of nid_to_phys() to struct damon_addr_range.  It also
> gets rid of the now-redundant local variable and pass the address range
> directly to damon_set_regions().

So, I don't think this change is required as-is.  I don't really want to add
addr_unit support for >4GiB 32bit system, either, unless it turns out to be
really needed.  I'd like to keep sample modules as simple as possible.  If the
code was confusing you because it is anyway casting the types, adding a comment
explaining the rationale might be a better change, in my opinion.


Thanks,
SJ

[...]


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

* Re: [PATCH v2] samples/damon/mtier: use damon_addr_range consistently
  2026-07-21  1:28 ` SJ Park
@ 2026-07-21  6:33   ` Enze Li
  0 siblings, 0 replies; 3+ messages in thread
From: Enze Li @ 2026-07-21  6:33 UTC (permalink / raw)
  To: SJ Park; +Cc: damon, linux-mm, linux-kernel, enze.li

Hi SJ,

On 7/21/26 9:28 AM, SJ Park wrote:
> Hello Enze,
> 
> On Mon, 20 Jul 2026 21:06:42 +0800 Enze Li <lienze@kylinos.cn> wrote:
> 
>> The DAMON provides struct damon_addr_range for unified address range
>> management.  However, the mtier sample still defines a local struct
>> region_range and mixes its usage with struct damon_addr_range in
>> damon_sample_mtier_build_ctx().
> 
> damon_addr_range is for DAMON core layer address system that uses 'unsigned
> long' as the address type.  Because 'mtier' is dealing directly with physical
> address, we use a dedicated struct for that purpose.  On 32bit systems having
> more than 4 GiB memory, this may be necessary.
> 
> 'mtier' doesn't really take care of the >4GiB 32bit system since it is simply
> casting the 'phys_addr_t' addresses into 'unsigned long' addresses.  But it
> might support it better in future, using the addr_unit parameter.
> 
>>
>> This patch removes the local struct region_range and changes the
>> parameter type of nid_to_phys() to struct damon_addr_range.  It also
>> gets rid of the now-redundant local variable and pass the address range
>> directly to damon_set_regions().
> 
> So, I don't think this change is required as-is.  I don't really want to add
> addr_unit support for >4GiB 32bit system, either, unless it turns out to be
> really needed.  I'd like to keep sample modules as simple as possible.  If the
> code was confusing you because it is anyway casting the types, adding a comment
> explaining the rationale might be a better change, in my opinion.

Thanks for the explanation and the feedback -- I agree that keeping
struct region_range is the right call.  Per your suggestion, I've
prepared a new patch that simply adds a comment to clarify the rationale.

Best Regards,
Enze

<...>



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

end of thread, other threads:[~2026-07-21  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 13:06 [PATCH v2] samples/damon/mtier: use damon_addr_range consistently Enze Li
2026-07-21  1:28 ` SJ Park
2026-07-21  6:33   ` Enze Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox