linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Usama Arif" <usamaarif642@gmail.com>,
	damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [RFC PATCH 6.1.y 1/2] mm/damon/core: skip applying scheme if region split for quota fails
Date: Sat,  7 Nov 2026 15:00:02 -0800	[thread overview]
Message-ID: <20261107230003.340646-1-sj@kernel.org> (raw)
In-Reply-To: <sashiko-outbox-203373@kernel.org>

On Sat, 07 Nov 2026 22:56:53 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] mm/damon: inflated tried stats in damon_do_apply_schemes() on
>   split failure
> --
> 
> commit 2d405ecddea503227b3b4138fe63cbeb95dc50b9
> Author: SJ Park <sj@kernel.org>
> 
> mm/damon/core: skip applying scheme if region split for quota fails
> 
> This commit changes damon_split_region_at() to return an error on memory
> allocation failure and skips applying the DAMOS scheme in
> damon_do_apply_schemes() when splitting a region to fit within the size
> quota fails.
> 
> Link: https://lore.kernel.org/20260901131850.98037-1-sj@kernel.org
> Link: https://lore.kernel.org/20260901131850.98037-2-sj@kernel.org
> Link: https://lore.kernel.org/20260718171523.87547-1-sj@kernel.org [1]
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index f0da5cb2b88a0..9206737d05ae7 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> 
> [ ... ]
> 
> > @@ -810,7 +810,8 @@ static void damon_do_apply_schemes(struct damon_ctx *c,
> >  						DAMON_MIN_REGION);
> >  				if (!sz)
> >  					goto update_stat;
> > -				damon_split_region_at(t, r, sz);
> > +				if (damon_split_region_at(t, r, sz))
> > +					goto update_stat;
> 
> [Severity: Low]
> Does jumping to update_stat here inflate s->stat.nr_tried and
> s->stat.sz_tried when damon_split_region_at() fails?
> 
> Unlike the !sz path right above, sz holds the non-zero remaining quota
> when damon_split_region_at() is called, and update_stat unconditionally
> accounts it:
> 
> mm/damon/core.c:damon_do_apply_schemes() {
> 	...
> update_stat:
> 		s->stat.nr_tried++;
> 		s->stat.sz_tried += sz;
> 	...
> }
> 
> Because c->ops.apply_scheme() is skipped and quota->charged_sz is not
> advanced, any subsequent matching regions in the same pass that also fail
> to split will repeatedly add sz to s->stat.sz_tried.

Good finding, but the user impact is trivial.  Same behavior exists in the
mainline, too.  Hence no blocker for this patch.

> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20261107224800.340250-1-sj@kernel.org?part=1
> 


Thanks,
SJ


  reply	other threads:[~2026-11-07 23:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 22:47 [RFC PATCH 6.1.y 0/2] mm/damon: porting fixes that cherry-pick failed on 2026-11-07 SJ Park
2026-11-07 22:47 ` [RFC PATCH 6.1.y 1/2] mm/damon/core: skip applying scheme if region split for quota fails SJ Park
2026-11-07 22:56   ` sashiko-bot
2026-11-07 23:00     ` SJ Park [this message]
2026-11-07 22:47 ` [RFC PATCH 6.1.y 2/2] mm/damon/core: remove unreachable damos charge_{target,addr}_from SJ Park
2026-11-07 23:02   ` sashiko-bot
2026-11-07 23:04     ` SJ 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=20261107230003.340646-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=damon@lists.linux.dev \
    --cc=linux-mm@kvack.org \
    --cc=sashiko-bot@kernel.org \
    --cc=usamaarif642@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).