All of lore.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SeongJae Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [RFC PATCH 08/14] mm/damon/core: add kdamond_call() debug_sanity check
Date: Wed, 20 May 2026 06:58:59 -0700	[thread overview]
Message-ID: <20260520135902.169663-1-sj@kernel.org> (raw)
In-Reply-To: <20260520065300.A51591F00893@smtp.kernel.org>

On Wed, 20 May 2026 06:52:52 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] The sanity check for region bounds in `damon_verify_ctx` uses an inverted condition, causing it to falsely trigger a kernel warning on all valid regions and fail to catch invalid ones.
> --
> 
> commit 7d803208aef5bc4f95dd9c37657de5b62618e8e6
> Author: SeongJae Park <sj@kernel.org>
> 
> mm/damon/core: add kdamond_call() debug_sanity check
> 
> This commit introduces a debug sanity check for the DAMON context state
> before handling damon_call_control objects in kdamond_call(). The check
> verifies region boundaries, overlaps, and the total region count under
> CONFIG_DAMON_DEBUG_SANITY.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> 
> [ ... ]
> 
> > @@ -3326,6 +3326,37 @@ static void kdamond_usleep(unsigned long usecs)
> >  		usleep_range_idle(usecs, usecs + 1);
> >  }
> >  
> > +#ifdef CONFIG_DAMON_DEBUG_SANITY
> > +static void damon_verify_ctx(struct damon_ctx *c)
> > +{
> > +	struct damon_target *t;
> > +	struct damon_region *r;
> > +
> > +	damon_for_each_target(t, c) {
> > +		struct damon_region *prev_r = NULL;
> > +		unsigned int nr_regions = 0;
> > +
> > +		damon_for_each_region(r, t) {
> > +			WARN_ONCE(r->ar.start <= r->ar.end,
> > +					"region start (%lu) <= end (%lu)\n",
> > +					r->ar.start, r->ar.end);
> 
> [Severity: High]
> Should this condition be inverted? WARN_ONCE triggers when the condition
> evaluates to true. Since a valid memory region typically has a start address
> strictly less than its end address, this evaluates to true for normal
> regions.
> 
> Could this trigger a spurious warning on the very first valid region
> encountered, and because it uses WARN_ONCE, prevent any actual regressions
> where start > end from being reported?

Nice catch.  start == end is also invalid because we disallow empty regions.  I
will update it to start >= end in the next version.

> 
> > +			WARN_ONCE(prev_r && prev_r->ar.end > r->ar.start,
> > +					"region overlap (%lu > %lu)\n",
> > +					prev_r->ar.end, r->ar.start);
> > +			prev_r = r;
> > +			nr_regions++;
> > +		}
> 
> [ ... ]
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260520062858.167011-1-sj@kernel.org?part=8


Thanks,
SJ

  reply	other threads:[~2026-05-20 13:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-20  6:28 [RFC PATCH 00/14] mm/damon: minor improvements for code readability and tests SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 01/14] mm/damon/core: safely handle no region case in damon_set_regions() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 02/14] mm/damon/core: do not use region out of a loop " SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 03/14] samples/damon/mtier: replace damon_add_region() with damon_set_regions() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 04/14] mm/damon/tests/vaddr-kunit: " SeongJae Park
2026-05-20  6:38   ` sashiko-bot
2026-05-20 13:53     ` SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 05/14] mm/damon/core: hide damon_add_region() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 06/14] mm/damon/core: hide damon_insert_region() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 07/14] mm/damon/core: hide damon_destroy_region() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 08/14] mm/damon/core: add kdamond_call() debug_sanity check SeongJae Park
2026-05-20  6:52   ` sashiko-bot
2026-05-20 13:58     ` SeongJae Park [this message]
2026-05-20 14:04     ` SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 09/14] mm/damon/core: remove damon_verify_nr_regions() SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 10/14] mm/damon/tests/core-kunit: add damon_set_regions() test cases SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 11/14] selftests/damon/sysfs.py: stop kdamonds before failing SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 12/14] selftests/damon/sysfs.sh: test monitoring intervals goal dir SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 13/14] selftests/damon/sysfs.sh: test addr_unit file existence SeongJae Park
2026-05-20  6:41   ` sashiko-bot
2026-05-20 14:08     ` SeongJae Park
2026-05-20 14:20       ` SeongJae Park
2026-05-20  6:28 ` [RFC PATCH 14/14] selftests/damon/sysfs.sh: test pause " SeongJae Park
2026-05-20  6:42   ` sashiko-bot
2026-05-20 14:11     ` 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=20260520135902.169663-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.