From: SeongJae Park <sj@kernel.org>
To: Enze Li <lienze@kylinos.cn>
Cc: SeongJae Park <sj@kernel.org>,
akpm@linux-foundation.org, damon@lists.linux.dev,
linux-mm@kvack.org, enze.li@gmx.com
Subject: Re: [PATCH] mm/damon: unify address range representation with damon_addr_range
Date: Thu, 29 Jan 2026 08:10:28 -0800 [thread overview]
Message-ID: <20260129161029.48991-1-sj@kernel.org> (raw)
In-Reply-To: <20260129100845.281734-1-lienze@kylinos.cn>
On Thu, 29 Jan 2026 18:08:45 +0800 Enze Li <lienze@kylinos.cn> wrote:
> Currently, DAMON defines two identical structures for representing
> address ranges: damon_system_ram_region and damon_addr_range. Both
> structures share the same semantic interpretation of a half-open
> interval [start, end), where the start address is inclusive and the end
> address is exclusive.
Nice finding!
>
> This duplication adds unnecessary redundancy and increases maintenance
> overhead. This patch replaces all uses of damon_system_ram_region with
> the more generic damon_addr_range structure, ensuring a unified type
> representation for address ranges within the DAMON subsystem. The
> change simplifies the codebase, improves readability, and avoids
> potential inconsistencies in future modifications.
Actually, there is another bug that need to be fixed. Nonetheless, that's
orthogonal to this patch, so it is not a blocker of this patch in my opinion.
>
> Signed-off-by: Enze Li <lienze@kylinos.cn>
Reviewed-by: SeongJae Park <sj@kernel.org>
> ---
> mm/damon/core.c | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 70efbf22a2b4..5e2724a4f285 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -2856,20 +2856,9 @@ static int kdamond_fn(void *data)
> return 0;
> }
>
> -/*
> - * struct damon_system_ram_region - System RAM resource address region of
> - * [@start, @end).
> - * @start: Start address of the region (inclusive).
> - * @end: End address of the region (exclusive).
> - */
> -struct damon_system_ram_region {
> - unsigned long start;
> - unsigned long end;
> -};
> -
> static int walk_system_ram(struct resource *res, void *arg)
> {
> - struct damon_system_ram_region *a = arg;
> + struct damon_addr_range *a = arg;
>
> if (a->end - a->start < resource_size(res)) {
> a->start = res->start;
The above line is storing 'resource_size_t' value to 'unsigned long' field.
That shouldn't be a problem on 64 bit environments. With introduction of
damon_ctx->addr_unit [1], however, DAMON started supporting environments that
'unsigned long' is not enough to represent the whole physical address range,
such as 32 bit environments with large phyiscal address extension. On such
environments, this could be a problem.
Nonetheless, this is orthogonal to this patch, as I mentioned above. So it
shouldn't block this patch. I will fix the problem unless someone steps up
faster than I.
[1] commit 09a616cbb371 ("mm/damon/core: add damon_ctx->addr_unit")
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-01-29 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 10:08 Enze Li
2026-01-29 16:10 ` SeongJae Park [this message]
2026-01-30 2:26 ` Quanmin Yan
2026-01-30 3:07 ` Quanmin Yan
2026-01-30 3:38 ` SeongJae Park
2026-01-31 1:56 ` 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=20260129161029.48991-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=enze.li@gmx.com \
--cc=lienze@kylinos.cn \
--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