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 3/7] mm/damon/sysfs-schemes: support quota goal complement flag
Date: Fri, 18 Sep 2026 18:37:47 -0700	[thread overview]
Message-ID: <20260919013749.89856-1-sj@kernel.org> (raw)
In-Reply-To: <20260919012635.E49A41F000FF@smtp.kernel.org>

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

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] mm/damon: integer underflow in DAMOS_QUOTA_SOME_MEM_PSI_US complement calculation
> --
> 
> commit cd02e1bd14a7884bf9a21f0cab584b1a0f9992ce
> Author: SJ Park <sj@kernel.org>
> 
> mm/damon/sysfs-schemes: support quota goal complement flag
> 
> This patch adds a new sysfs file for the quota goal directory to allow
> setting and getting the quota goal metric complement flag value.
> 
> > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> > index 06af417bc9a2f..8f083611741fd 100644
> > --- a/mm/damon/sysfs-schemes.c
> > +++ b/mm/damon/sysfs-schemes.c
> 
> [ ... ]
> 
> > @@ -2869,7 +2898,8 @@ static int damos_sysfs_add_quota_score(
> >  		if (!sysfs_goal->target_value)
> >  			continue;
> >  
> > -		goal = damos_new_quota_goal(sysfs_goal->metric, false,
> > +		goal = damos_new_quota_goal(sysfs_goal->metric,
> > +				sysfs_goal->complement,
> >  				sysfs_goal->target_value);
> >  		if (!goal)
> >  			return -ENOMEM;
> 
> [Severity: High]
> Now that complement = true can be configured via sysfs, does this expose
> an integer underflow in damos_set_quota_goal_current_value()?
> 
> If a user configures a DAMOS quota goal using DAMOS_QUOTA_SOME_MEM_PSI_US
> with complement = true, the actual elapsed wall-clock time between
> evaluations can exceed the configured s->quota.reset_interval due to
> routine thread scheduling delays or high system load.
> 
> In mm/damon/core.c:damos_set_quota_goal_current_value(), the accumulated
> PSI time (goal->current_value) could then exceed reset_interval * 1000,
> underflowing the unsigned subtraction:
> 
> 	if (goal->metric = DAMOS_QUOTA_SOME_MEM_PSI_US) {
> 		goal->current_value = s->quota.reset_interval * 1000 -
> 			goal->current_value;
> 		return;
> 	}
> 
> Unlike the basis-point metrics below it, this lacks a safety bounds check.
> The unsigned integer underflow results in an erroneously massive quota score.
> 
> This causes damon_feed_loop_next_input() to evaluate score >= goal * 2 and
> return the minimum possible input (min_input), severely throttling the quota
> size (esz) to a minimal value.
> 
> This effectively disables DAMOS scheme actions for that window, despite the
> system being under severe memory pressure, which is exactly when tuning
> is most important.

I will fix in the next revision.

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


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 [this message]
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

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=20260919013749.89856-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