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>, damon@lists.linux.dev
Subject: Re: [RFC PATCH v2 7/7] Docs/ABI/damon: update for quota goal metric complement sysfs file
Date: Fri, 18 Sep 2026 18:38:39 -0700	[thread overview]
Message-ID: <20260919013840.89998-1-sj@kernel.org> (raw)
In-Reply-To: <20260919012322.2F2241F000FF@smtp.kernel.org>

On Sat, 19 Sep 2026 01:23:21 +0000 sashiko-bot@kernel.org wrote:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] mm: integer underflow in damos_set_quota_goal_current_value()
> --
> 
> commit f2de2d4493473c2c847f3ad213eaef640f0e1600
> Author: SJ Park <sj@kernel.org>
> 
> mm/damon/core: introduce damos_quota_goal->complement
> 
> Introduce damos_quota_goal->complement for specifying whether to use a
> complemented value of the given goal target metric. Add the field to
> the data structure and implement essential core support.
> 
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > index 2258b72da7a78..9fd08cbfacd8c 100644
> > --- a/mm/damon/core.c
> > +++ b/mm/damon/core.c
> 
> [ ... ]
> 
> > @@ -3238,6 +3239,23 @@ static void damos_set_quota_goal_current_value(struct damon_ctx *c,
> >  	default:
> >  		break;
> >  	}
> > +	if (!goal->complement)
> > +		return;
> > +
> > +	/* updte current_value to complemented value */
> > +
> > +	/* for user_input, users set complemented value on their own */
> > +	if (goal->metric = DAMOS_QUOTA_USER_INPUT)
> > +		return;
> > +	if (goal->metric = DAMOS_QUOTA_SOME_MEM_PSI_US) {
> > +		goal->current_value = s->quota.reset_interval * 1000 -
> > +			goal->current_value;
> 
> [Severity: High]
> Does this unprotected subtraction in damos_set_quota_goal_current_value() risk
> an integer underflow?
> 
> If a user configures DAMOS_QUOTA_SOME_MEM_PSI_US with complement enabled via
> sysfs and sets a target_value greater than reset_interval * 1000, the initial
> round (where current_value = target_value) will immediately underflow.
> 
> Furthermore, if the kdamond thread is delayed by the scheduler beyond the reset
> interval, the measured PSI time can naturally exceed reset_interval * 1000,
> which would also trigger the underflow.
> 
> This underflow would result in a huge current_value (near ULONG_MAX), which is
> then fed into damos_quota_score(), producing an astronomically high tuning
> score that aggressively drops the effective quota to zero, breaking the quota
> regulation mechanism.

I will fix this in the next spin.

> 
> > +		return;
> > +	}
> > +	if (goal->current_value < 10000)
> > +		goal->current_value = 10000 - goal->current_value;
> > +	else
> > +		goal->current_value = 0;
> >  }
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260919011359.88921-1-sj@kernel.org?part=7
> 


Thanks,
SJ

      reply	other threads:[~2026-09-19  1:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19  1:13 [RFC PATCH v2 0/7] mm/damon: introduce damos quota goal target metric complement flag SJ Park
2026-09-19  1:13 ` [RFC PATCH v2 1/7] mm/damon/core: introduce damos_quota_goal->complement SJ Park
2026-09-19  1:25   ` sashiko-bot
2026-09-19  1:27     ` SJ Park
2026-09-19  1:13 ` [RFC PATCH v2 2/7] mm/damon: add complement argument to damos_new_quota_goal() SJ Park
2026-09-19  1:23   ` sashiko-bot
2026-09-19  1:36     ` SJ Park
2026-09-19  1:13 ` [RFC PATCH v2 3/7] mm/damon/sysfs-schemes: support quota goal complement flag SJ Park
2026-09-19  1:26   ` sashiko-bot
2026-09-19  1:37     ` SJ Park
2026-09-19  1:13 ` [RFC PATCH v2 4/7] mm/damon/tests/core-kunit: test quota_goal->complement commit SJ Park
2026-09-19  1:17   ` sashiko-bot
2026-09-19  1:13 ` [RFC PATCH v2 5/7] Docs/mm/damon/design: document damos quota goal complement flag SJ Park
2026-09-19  1:16   ` sashiko-bot
2026-09-19  1:13 ` [RFC PATCH v2 6/7] Docs/admin-guide/mm/damon/usage: update for quota goal complement file SJ Park
2026-09-19  1:16   ` sashiko-bot
2026-09-19  1:13 ` [RFC PATCH v2 7/7] Docs/ABI/damon: update for quota goal metric complement sysfs file SJ Park
2026-09-19  1:23   ` sashiko-bot
2026-09-19  1:38     ` 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=20260919013840.89998-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox