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 3/7] mm/damon/sysfs-schemes: support quota goal complement flag
Date: Fri, 18 Sep 2026 08:09:15 -0700 [thread overview]
Message-ID: <20260918150916.86314-1-sj@kernel.org> (raw)
In-Reply-To: <20260918150536.9AA851F000FF@smtp.kernel.org>
On Fri, 18 Sep 2026 15:05:35 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] mm: unsigned integer underflow in damos quota complement calculation
> --
>
> commit 8f39260b8b618fca6e69e55388bee135a86971f3
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/sysfs-schemes: support quota goal complement flag
>
> This commit adds a new sysfs file to support setting and getting the
> quota goal metric complement flag. It exposes this flag to user space,
> allowing the complement value to be passed to damos_new_quota_goal().
>
> > 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);
>
> [Severity: High]
> Does exposing the complement flag to user space introduce an integer
> underflow risk for PSI metrics?
>
> When the complement flag is enabled via sysfs for a
> DAMOS_QUOTA_SOME_MEM_PSI_US goal, damos_set_quota_goal_current_value()
> in mm/damon/core.c performs a direct subtraction:
>
> if (goal->metric == DAMOS_QUOTA_SOME_MEM_PSI_US)
> goal->current_value = s->quota.reset_interval * 1000 -
> goal->current_value;
> else
> goal->current_value = 10000 - goal->current_value;
>
> Because DAMON runs in a preemptible worker thread, natural scheduling
> delays can cause the elapsed PSI time (initially stored in
> goal->current_value) to exceed the nominal reset_interval * 1000.
>
> If this happens, the subtraction underflows, wrapping current_value to
> near ULONG_MAX. This corrupted value is then used to calculate the quota
> score, which completely breaks DAMON's throttling logic.
I will fix the core logic in the next revision.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260918142827.85303-1-sj@kernel.org?part=3
Thanks,
SJ
next prev parent reply other threads:[~2026-09-18 15:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 14:28 [RFC PATCH 0/7] mm/damon: introduce damos quota goal target metric complement flag SJ Park
2026-09-18 14:28 ` [RFC PATCH 1/7] mm/damon/core: introduce damos_quota_goal->complement SJ Park
2026-09-18 14:48 ` sashiko-bot
2026-09-18 15:08 ` SJ Park
2026-09-18 14:28 ` [RFC PATCH 2/7] mm/damon: add complement argument to damos_new_quota_goal() SJ Park
2026-09-18 14:56 ` sashiko-bot
2026-09-18 14:28 ` [RFC PATCH 3/7] mm/damon/sysfs-schemes: support quota goal complement flag SJ Park
2026-09-18 15:05 ` sashiko-bot
2026-09-18 15:09 ` SJ Park [this message]
2026-09-18 14:28 ` [RFC PATCH 4/7] mm/damon/tests/core-kunit: test quota_goal->complement commit SJ Park
2026-09-18 15:07 ` sashiko-bot
2026-09-18 14:28 ` [RFC PATCH 5/7] Docs/mm/damon/design: document damos quota goal complement flag SJ Park
2026-09-18 15:07 ` sashiko-bot
2026-09-18 14:28 ` [RFC PATCH 6/7] Docs/admin-guide/mm/damon/usage: update for quota goal complement file SJ Park
2026-09-18 15:09 ` sashiko-bot
2026-09-18 15:11 ` SJ Park
2026-09-18 14:28 ` [RFC PATCH 7/7] Docs/ABI/damon: update for quota goal metric complement sysfs file SJ Park
2026-09-18 15:21 ` sashiko-bot
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=20260918150916.86314-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.