DAMON development mailing list
 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: [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target()
Date: Thu,  3 Dec 2026 07:40:44 -0800	[thread overview]
Message-ID: <20261203154045.733625-1-sj@kernel.org> (raw)
In-Reply-To: <sashiko-outbox-248105@kernel.org>

On Thu, 03 Dec 2026 15:26:47 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [Medium] mm/damon: core filter runs before access pattern in
>   __damos_valid_target()
> - [Low] mm/damon: commit message misstates parameter added to
>   __damos_valid_target()
> - [Low] mm/damon: redundant damon_sz_region() assignment in
>   damos_apply_scheme()
> --
> 
> commit 65ff401f1d42c531dc70b0b39a702a59a8905c6f
> Author: SJ Park <sj@kernel.org>
> 
> mm/damon/core: apply damos core filter in __damos_valid_target()
> 
> This commit moves DAMOS core filter evaluation into __damos_valid_target()
> and splits out damos_access_pattern_eligible() for callers that only check
> the access pattern.
> 
> > Treat DAMOS core filter as the primary method.  Handle core filters and
> > damos_access_pattern together in the central region selection function,
> > __damos_valid_target().  Update __damos_valid_target() to receive
> > damon_ctx, to allow it access to core filters.
> 
> [Severity: Low]
> __damos_valid_target() already received struct damon_ctx *c; this commit
> adds struct damon_target *t so it can be passed to damos_core_filter_out().

Good check.  I will fix the commit message.

> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 2766ebec01501..b0e9325e032b6 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> 
> [ ... ]
> 
> > @@ -2550,6 +2554,15 @@ static bool __damos_valid_target(struct damon_region *r, struct damos *s,
> >  		r->age <= s->pattern.max_age_region;
> >  }
> >  
> > +static bool __damos_valid_target(struct damon_region *r, struct damos *s,
> > +		struct damon_ctx *c, struct damon_target *t)
> > +{
> > +	if (damos_core_filter_out(c, t, r, s))
> > +		return false;
> > +
> > +	return damos_access_pattern_eligible(r, s, c);
> > +}
> 
> [Severity: Medium]
> Can running damos_core_filter_out() before damos_access_pattern_eligible()
> cause DAMOS_FILTER_TYPE_ADDR splits to break region size checks?
> 
> For a partially overlapping DAMOS_FILTER_TYPE_ADDR filter,
> damos_filter_match() calls damon_split_region_at() and shrinks r in place.
> damos_access_pattern_eligible() then checks min_sz_region and max_sz_region
> against the post-split slice instead of the original region.
> 
> A region larger than max_sz_region can then be split into a smaller slice
> and erroneously receive the scheme action, while an eligible region with a
> narrower filter overlap is falsely rejected under min_sz_region.  Regions
> failing nr_accesses or age are also split before later schemes evaluate them.
> 
> Checking damos_access_pattern_eligible() before damos_core_filter_out()
> would preserve the previous semantics.

Good point.  I will update this code to check damos_access_pattern before core
filters.

> 
> [ ... ]
> 
> > @@ -2896,8 +2909,6 @@ 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;
> >  		sz = damon_sz_region(r);
> >  		if (damos_quota_is_set(quota) &&
> >  				quota->charged_sz + sz > quota->esz) {
> 
> [Severity: Low]
> Is this sz = damon_sz_region(r) assignment now redundant?  sz is already
> initialized to damon_sz_region(r) at the start of damos_apply_scheme(), and
> nothing modifies r in between now that damos_core_filter_out() has been
> removed here.

Correct.  I will remove the redundant assignment.

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


Thanks,
SJ

  reply	other threads:[~2026-12-03 15:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:08 [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method SJ Park
2026-12-03 15:08 ` [PATCH v2 1/3] mm/damon/tests/core-kunit: drop apply_scheme()-internal filter tests SJ Park
2026-12-03 15:19   ` sashiko-bot
2026-12-03 15:36     ` SJ Park
2026-12-03 15:08 ` [PATCH v2 2/3] mm/damon/core: apply damos core filter in __damos_valid_target() SJ Park
2026-12-03 15:26   ` sashiko-bot
2026-12-03 15:40     ` SJ Park [this message]
2026-12-03 15:08 ` [PATCH v2 3/3] mm/damon/api: clarify node_eligible_mem_bp is access pattern-eligible SJ Park
2026-12-03 15:26 ` [PATCH v2 0/3] mm/damon: treat DAMOS core filters as a primary target selection method sashiko-bot
2026-12-03 15:42 ` 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=20261203154045.733625-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