All of 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>, damon@lists.linux.dev
Subject: Re: [RFC PATCH v5 1/8] mm/damon/core: introduce damos_quota_goal->complement
Date: Mon, 28 Sep 2026 02:47:35 -0700	[thread overview]
Message-ID: <20260928094737.17117-1-sj@kernel.org> (raw)
In-Reply-To: <20260928094441.108CE1F00893@smtp.kernel.org>

On Mon, 28 Sep 2026 09:44:40 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] mm/damon: integer overflow in damos_set_psi_current_val on 32-bit systems
> --
> 
> commit 2c98b9664c0f8cdd559874386842cae96a9ea8cb
> Author: SJ Park <sj@kernel.org>
> mm/damon/core: introduce damos_quota_goal->complement
> 
> This commit introduces the complement flag to damos_quota_goal, allowing the
> system to use the complemented value of a target metric. It adds the field
> to the data structure and implements support for it during quota goal commits
> and metric value retrievals.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 733025b367457..270ce9c85a2ce 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> 
> [ ... ]
> 
> > @@ -2960,10 +2961,18 @@ static void damos_set_psi_current_val(u64 now_psi_total,
> >  		struct damos_quota_goal *goal, struct damos *s)
> >  {
> >  	u64 last_psi_total = goal->last_psi_total;
> > +	unsigned long val;
> >  
> >  	goal->last_psi_total = now_psi_total;
> >  	if (last_psi_total != U64_MAX) {
> > -		goal->current_value = now_psi_total - last_psi_total;
> > +		val = now_psi_total - last_psi_total;
> > +		if (goal->complement) {
> > +			if (val < s->quota.reset_interval * 1000)
> > +				val = s->quota.reset_interval * 1000 - val;
> 
> [Severity: Low]
> Does this multiplication risk an integer overflow on 32-bit systems?
> 
> On 32-bit systems, unsigned long is 32 bits, with a maximum value of ~4.29
> billion. If a user configures reset_interval via sysfs to a value larger
> than 4,294,967 (about 71.5 minutes), the multiplication
> s->quota.reset_interval * 1000 will overflow unsigned long.
> 
> This causes the auto-tuning goal complement metric to evaluate with a
> truncated, incorrect value. While 32-bit systems running DAMON with 71+ 
> minute intervals are extremely rare, could this cause unexpected behavior
> when long intervals are configured?

Yes, that's extremely rare.  Also sane users would use the new feature after
testing.  Not a blocker of this series in my opinion.

> 
> > +			else
> > +				val = 0;
> > +		}
> > +		goal->current_value = val;
> >  		return;
> >  	}
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260928093342.16584-1-sj@kernel.org?part=1
> 


Thanks,
SJ

  reply	other threads:[~2026-09-28  9:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28  9:33 [RFC PATCH v5 0/8] mm/damon: introduce damos quota goal target metric complement flag SJ Park
2026-09-28  9:33 ` [RFC PATCH v5 1/8] mm/damon/core: introduce damos_quota_goal->complement SJ Park
2026-09-28  9:44   ` sashiko-bot
2026-09-28  9:47     ` SJ Park [this message]
2026-09-28  9:33 ` [RFC PATCH v5 2/8] mm/damon/core: add complement argument to damos_new_quota_goal() SJ Park
2026-09-28  9:42   ` sashiko-bot
2026-09-28  9:33 ` [RFC PATCH v5 3/8] mm/damon/sysfs-schemes: support quota goal complement flag SJ Park
2026-09-28  9:40   ` sashiko-bot
2026-09-28  9:33 ` [RFC PATCH v5 4/8] mm/damon/tests/core-kunit: test quota_goal->complement commit SJ Park
2026-09-28  9:37   ` sashiko-bot
2026-09-28  9:33 ` [RFC PATCH v5 5/8] selftests/damon/sysfs.sh: test quota goal complement flag file SJ Park
2026-09-28  9:36   ` sashiko-bot
2026-09-28  9:33 ` [RFC PATCH v5 6/8] Docs/mm/damon/design: document damos quota goal complement flag SJ Park
2026-09-28  9:39   ` sashiko-bot
2026-09-28  9:33 ` [RFC PATCH v5 7/8] Docs/admin-guide/mm/damon/usage: update for quota goal complement file SJ Park
2026-09-28  9:38   ` sashiko-bot
2026-09-28  9:33 ` [RFC PATCH v5 8/8] Docs/ABI/damon: update for quota goal metric complement sysfs file SJ Park
2026-09-28  9:43   ` sashiko-bot
2026-09-28  9:49     ` 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=20260928094737.17117-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.