DAMON development mailing list
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SeongJae Park <sj@kernel.org>,
	"Ravi Jonnalagadda" <ravis.opensrc@gmail.com>,
	damon@lists.linux.dev
Subject: Re: [PATCH v9.1] mm/damon: add node_eligible_mem_bp goal metric
Date: Mon, 27 Apr 2026 07:53:30 -0700	[thread overview]
Message-ID: <20260427145331.112239-1-sj@kernel.org> (raw)
In-Reply-To: <20260427012429.D25C2C2BCAF@smtp.kernel.org>

On Mon, 27 Apr 2026 01:24:29 +0000 sashiko-bot@kernel.org wrote:

> Sashiko AI review found 3 potential issue(s):
> - [High] Data truncation and arithmetic overflow in metric calculation on 32-bit systems.
> - [High] Missing `cond_resched()` inside the inner PFN-walking loop causes CPU soft lockups.

Not new Sashiko findings.  Above two issues are not real problems or better to
see if the issue can really happen.  I explained detailed reason on previous
Sashiko reviews.

> - [High] Address advancement logic is vulnerable to wrap-around infinite loops.

This is a new and good finding.  I asked a fix on my reply to the patch.

> --
> 
> commit 10100659661304515a414f3a15324e8278667f42
> Author: Ravi Jonnalagadda <ravis.opensrc@gmail.com>
> 
> mm/damon: add node_eligible_mem_bp goal metric
> 
> This commit introduces the DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP goal metric to
> track the ratio of scheme-eligible memory on a specific NUMA node, allowing
> the quota autotuner to adjust based on spatial memory distribution.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 3dbbbfdeff71..22d6eb3a974d 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> [ ... ]
> > +static phys_addr_t damos_calc_eligible_bytes(struct damon_ctx *c,
> > +		struct damos *s, int nid, phys_addr_t *total)
> > +{
> [ ... ]
> > +			/* Convert from core address units to physical bytes */
> > +			addr = (phys_addr_t)r->ar.start * c->addr_unit;
> > +			end_addr = (phys_addr_t)r->ar.end * c->addr_unit;
> > +			while (addr < end_addr) {
> > +				struct folio *folio;
> > +				phys_addr_t folio_start, folio_end;
> > +				phys_addr_t overlap_start, overlap_end;
> > +				phys_addr_t counted;
> > +
> > +				folio = damon_get_folio(PHYS_PFN(addr));
> > +				if (!folio) {
> > +					addr = PAGE_ALIGN_DOWN(addr + PAGE_SIZE);
> 
> If a DAMON region extends to the upper boundary of the physical address space,
> could addr + PAGE_SIZE overflow and wrap around to 0?
> 
> If addr wraps to 0, addr < end_addr would remain true, which might cause an
> unrecoverable infinite loop.

Good finding.  I asked another version for fix of this, on my reply to the
original patch.


Thanks,
SJ

[...]

  reply	other threads:[~2026-04-27 14:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27  1:02 [PATCH v9.1] mm/damon: add node_eligible_mem_bp goal metric Ravi Jonnalagadda
2026-04-27  1:24 ` sashiko-bot
2026-04-27 14:53   ` SeongJae Park [this message]
2026-04-27 14:58     ` [PATCH for-sashiko] mm/damon/core: (fixup) break calc_eligible_bytes() loop if addr overflows SeongJae Park
2026-04-27 14:49 ` [PATCH v9.1] mm/damon: add node_eligible_mem_bp goal metric 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=20260427145331.112239-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=ravis.opensrc@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox