From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>, damon@lists.linux.dev
Subject: Re: [PATCH 1/8] mm/damon/core: introduce damos_quota_goal->complement
Date: Tue, 29 Sep 2026 01:16:02 -0700 [thread overview]
Message-ID: <20260929081603.42230-1-sj@kernel.org> (raw)
In-Reply-To: <20260929081239.A69AC1F000FF@smtp.kernel.org>
On Tue, 29 Sep 2026 08:12:39 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] damon: integer overflow in psi complement calculation on 32-bit
> --
>
> commit 194cde60eb24e43a85afddadebba1bd09c82f1e0
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/core: introduce damos_quota_goal->complement
>
> This commit introduces the complement flag to the damos_quota_goal structure
> to specify whether to use a complemented value of the goal target metric. It
> also implements the core logic to handle this flag during quota goal commit
> and metric retrieval.
>
> > diff --git a/mm/damon/core.c b/mm/damon/core.c
> > --- 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 calculation overflow on 32-bit systems?
>
> On 32-bit architectures, s->quota.reset_interval is a 32-bit unsigned long.
> Multiplying it by the integer literal 1000 will overflow before the
> comparison and subtraction if the user configures a reset_interval_ms
> greater than 4,294,967 (around 71.5 minutes).
>
> While such a high interval is atypical for DAMON's continuous monitoring,
> it is technically reachable via sysfs since the sysfs store function does
> not bound the value beyond the maximum unsigned long value.
Yes, it is atypical and extreme setup. Sane users ain't use such setup without
testing. I think it wouldn't be too late to revisit this after a report from a
user is arrived. I will also consider making a better handling of the corner
case. But not a blocker of this series.
>
> > + else
> > + val = 0;
> > + }
> > + goal->current_value = val;
> > return;
> > }
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260929080113.41708-1-sj@kernel.org?part=1
>
Thanks,
SJ
next prev parent reply other threads:[~2026-09-29 8:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 8:01 [PATCH 0/8] mm/damon: introduce damos quota goal target metric complement flag SJ Park
2026-09-29 8:01 ` [PATCH 1/8] mm/damon/core: introduce damos_quota_goal->complement SJ Park
2026-09-29 8:12 ` sashiko-bot
2026-09-29 8:16 ` SJ Park [this message]
2026-09-29 10:24 ` Gutierrez Asier
2026-09-29 10:34 ` SJ Park
2026-09-29 8:01 ` [PATCH 2/8] mm/damon/core: add complement argument to damos_new_quota_goal() SJ Park
2026-09-29 8:07 ` sashiko-bot
2026-09-29 10:25 ` Gutierrez Asier
2026-09-29 8:01 ` [PATCH 3/8] mm/damon/sysfs-schemes: support quota goal complement flag SJ Park
2026-09-29 8:06 ` sashiko-bot
2026-09-29 8:01 ` [PATCH 4/8] mm/damon/tests/core-kunit: test quota_goal->complement commit SJ Park
2026-09-29 8:03 ` sashiko-bot
2026-09-29 8:01 ` [PATCH 5/8] selftests/damon/sysfs.sh: test quota goal complement flag file SJ Park
2026-09-29 8:07 ` sashiko-bot
2026-09-29 8:01 ` [PATCH 6/8] Docs/mm/damon/design: document damos quota goal complement flag SJ Park
2026-09-29 8:06 ` sashiko-bot
2026-09-29 8:01 ` [PATCH 7/8] Docs/admin-guide/mm/damon/usage: update for quota goal complement file SJ Park
2026-09-29 8:02 ` sashiko-bot
2026-09-29 8:01 ` [PATCH 8/8] Docs/ABI/damon: update for quota goal metric complement sysfs file SJ Park
2026-09-29 8:03 ` sashiko-bot
2026-09-29 8:17 ` [PATCH 0/8] mm/damon: introduce damos quota goal target metric complement flag 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=20260929081603.42230-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.