From: SeongJae Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [PATCH 1/7] mm/damon: introduce damon_set_region_system_rams_default()
Date: Tue, 28 Apr 2026 22:22:48 -0700 [thread overview]
Message-ID: <20260429052249.91279-1-sj@kernel.org> (raw)
In-Reply-To: <20260429043902.E8FFDC19425@smtp.kernel.org>
On Wed, 29 Apr 2026 04:39:02 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] The default region setup creates a single contiguous bounding box encompassing all System RAM resources, incorrectly including unpopulated memory holes.
> - [High] Integer overflow during physical address boundary calculation (`arg.res.end + 1`) can cause DAMON initialization to fail.
Both are not a blocker of this patch in my opinion. Please read below for
details.
> --
>
> commit cd855b0d7d334ccf9a13e1331105a3281e5b0aeb
> Author: SeongJae Park <sj@kernel.org>
>
> mm/damon: introduce damon_set_region_system_rams_default()
>
> Introduces a default target setup for DAMON that sets a physical address
> range covering all System RAM resources when the caller doesn't specify
> a region.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 05e4bef367db..980a31cd3498 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> [ ... ]
> > +static bool damon_find_system_rams_range(unsigned long *start,
> > + unsigned long *end, unsigned long addr_unit)
> > +{
> > + struct damon_system_ram_range_walk_arg arg = {};
> > +
> > + walk_system_ram_res(0, -1, &arg, damon_system_ram_walk_fn);
> > + if (!arg.walked)
> > + return false;
> > + *start = damon_res_to_core_addr(arg.res.start, addr_unit);
> > + *end = damon_res_to_core_addr(arg.res.end + 1, addr_unit);
>
> Can arg.res.end + 1 overflow here?
>
> If a 32-bit system has physical memory extending to the end of the address
> space, arg.res.end will be the maximum representable value. Adding 1 would
> overflow to 0, making *end 0. The subsequent check if (*end <= *start)
> would then evaluate to true, causing the function to silently return false
> and abort initialization with -EINVAL.
Yes, such corner case could exist. But, similar overflow-caused initialization
could happen even before this patch, if the biggest System RAM's end address is
same to the U32T_MAX. And even in the corner case, failing initialization
shouldn't cause a real problem. The user could manually set the monitoring
regions and work.
So, not a blocker of this patch.
>
> > + if (*end <= *start)
> > + return false;
> > + return true;
> > +}
> [ ... ]
> > +int damon_set_region_system_rams_default(struct damon_target *t,
> > + unsigned long *start, unsigned long *end,
> > + unsigned long addr_unit, unsigned long min_region_sz)
> > +{
> > + struct damon_addr_range addr_range;
> > +
> > + if (*start > *end)
> > + return -EINVAL;
> > +
> > + if (!*start && !*end &&
> > + !damon_find_system_rams_range(start, end, addr_unit))
> > + return -EINVAL;
> > +
> > + addr_range.start = *start;
> > + addr_range.end = *end;
> > + return damon_set_regions(t, &addr_range, 1, min_region_sz);
>
> Does this create a single bounding box encompassing all System RAM resources,
> including unpopulated memory holes?
>
> On systems with sparse physical memory layouts, this combined range will
> encompass massive memory holes. Because DAMON uses uniform random sampling
> within a region to estimate access frequencies, samples landing in the gaps
> will inherently register as unaccessed, diluting the perceived access rates
> and preventing effective adaptive region splitting and merging.
As also answered to the same previous questions, DAMON's adaptive regions
adjustment mechanism should solve this accuracy issue.
So, not a blocker for this patch.
>
> Could the implementation instead construct an array of multiple ranges,
> one for each distinct System RAM resource, and pass them to
> damon_set_regions()?
When the number of such distinct areas is high, because distict regions cannot
be merged, it will degrade the accuracy. So, no. Like vaddr, adding a finite
number of biggest gaps might make sense. But, it wouldn't be late to revist
after such problematic real use case is found.
Thanks,
SJ
[...]
next prev parent reply other threads:[~2026-04-29 5:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 4:12 [PATCH 0/7] mm/damon/reclaim,lru_sort: monitor all system rams by default SeongJae Park
2026-04-29 4:12 ` [PATCH 1/7] mm/damon: introduce damon_set_region_system_rams_default() SeongJae Park
2026-04-29 4:39 ` sashiko-bot
2026-04-29 5:22 ` SeongJae Park [this message]
2026-04-29 4:12 ` [PATCH 2/7] mm/damon/reclaim: cover all system rams SeongJae Park
2026-04-29 5:23 ` sashiko-bot
2026-04-29 5:41 ` SeongJae Park
2026-04-29 4:12 ` [PATCH 3/7] mm/damon/lru_sort: " SeongJae Park
2026-04-29 6:03 ` sashiko-bot
2026-04-29 6:06 ` SeongJae Park
2026-04-29 4:12 ` [PATCH 4/7] mm/damon/core: remove damon_set_region_biggest_system_ram_default() SeongJae Park
2026-04-29 4:12 ` [PATCH 5/7] mm/damon/stat: use damon_set_region_system_rams_default() SeongJae Park
2026-04-29 4:12 ` [PATCH 6/7] Docs/admin-guide/mm/damon/reclaim: update for entire memory monitoring SeongJae Park
2026-04-29 7:02 ` sashiko-bot
2026-04-29 14:27 ` SeongJae Park
2026-04-29 4:12 ` [PATCH 7/7] Docs/admin-guide/mm/damon/lru_sort: " SeongJae Park
2026-04-29 14:30 ` [PATCH 0/7] mm/damon/reclaim,lru_sort: monitor all system rams by default 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=20260429052249.91279-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-bot@kernel.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.