Linux-mm Archive on lore.kernel.org
 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>,
	damon@lists.linux.dev, linux-mm@kvack.org
Subject: Re: [RFC PATCH mm-hotfixes-unstable] mm/damon/core: do not update stat for core filter rejecting region
Date: Fri, 27 Nov 2026 12:59:17 -0800	[thread overview]
Message-ID: <20261127205919.95770-1-sj@kernel.org> (raw)
In-Reply-To: <sashiko-outbox-238270@kernel.org>

On Fri, 27 Nov 2026 20:48:16 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] mm/damon/core: stale region size in damos_apply_scheme()
>   corrupts regions
> --
> 
> commit 2aba0f31066065a1efc163e77a7548d189458afa
> Author: SJ Park <sj@kernel.org>
> 
> mm/damon/core: do not update stat for core filter rejecting region
> 
> This commit moves the damos_core_filter_out() check in
> damos_apply_scheme() ahead of the quota enforcement check so that
> regions rejected by core filters are not accounted in DAMOS statistics
> when the quota is full.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 0e6b361f97ea6..e0ea93de100d8 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> > @@ -2785,6 +2785,8 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
> >  	}
> >  
> >  	if (c->ops.apply_scheme) {
> > +		if (damos_core_filter_out(c, t, r, s))
> > +			return;
> >  		if (damos_quota_is_set(quota) &&
> >  				quota->charged_sz + sz > quota->esz) {
> >  			sz = ALIGN_DOWN(quota->esz - quota->charged_sz,
> > @@ -2794,8 +2796,6 @@ static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
> >  			if (damon_split_region_at(t, r, sz))
> >  				goto update_stat;
> >  		}
> > -		if (damos_core_filter_out(c, t, r, s))
> > -			return;
> >  		sz = damon_sz_region(r);
> 
> [Severity: High]
> Should sz be refreshed with damon_sz_region(r) right after
> damos_core_filter_out() rather than after the quota check?
> 
> damos_core_filter_out() -> damos_filter_match() can split r in place and
> shrink r->ar.end for a DAMOS_FILTER_TYPE_ADDR filter.  Because sz still
> holds the pre-filter region size during the quota check, when the
> remaining aligned quota falls between the post-filter and pre-filter
> sizes, damon_split_region_at(t, r, sz) is called with sz >=
> damon_sz_region(r).  That expands r->ar.end back across the filter
> boundary and inserts a zero-length or inverted region (start >= end)
> into t->regions_list.

Nice catch, I will fix in the next spin.

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


Thanks,
SJ


      reply	other threads:[~2026-11-27 20:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 20:39 [RFC PATCH mm-hotfixes-unstable] mm/damon/core: do not update stat for core filter rejecting region SJ Park
2026-11-27 20:48 ` sashiko-bot
2026-11-27 20:59   ` SJ Park [this message]

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=20261127205919.95770-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 \
    /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