From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v4 1/7] mm/damon/core: introduce damos_quota_goal->complement
Date: Sun, 27 Sep 2026 12:17:14 +0000 [thread overview]
Message-ID: <20260927121715.19E841F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927120533.50484-2-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm: integer overflow in damos_set_psi_current_val on 32-bit
--
commit 4f53a2ca54f02309422119354f04050f15950222
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. Handle the
flag in the quota goal commit and current quota goal metric value
retrieval.
> 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: Medium]
Will this calculation overflow on 32-bit platforms?
When reset_interval is configured to a value > 4,294,967 ms (around 1.19
hours), s->quota.reset_interval * 1000 will silently overflow when evaluated
as a 32-bit unsigned long multiplication.
If this wraps around, could it corrupt the complemented PSI value and lead
to faulty auto-tuning feedback? Does this need a cast or different typing to
avoid the overflow?
> + else
> + val = 0;
> + }
> + goal->current_value = val;
> return;
> }
> /* uninitialized last_psi_total; make no effect this round */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260927120533.50484-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-09-27 12:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 12:05 [RFC PATCH v4 0/7] snapshot_set_swap_area() unpins the previously selected swap device and SJ Park
2026-09-27 12:05 ` [RFC PATCH v4 1/7] mm/damon/core: introduce damos_quota_goal->complement SJ Park
2026-09-27 12:17 ` sashiko-bot [this message]
2026-09-27 12:22 ` SJ Park
2026-09-27 12:05 ` [RFC PATCH v4 2/7] mm/damon/core: add complement argument to damos_new_quota_goal() SJ Park
2026-09-27 12:12 ` sashiko-bot
2026-09-27 12:30 ` SJ Park
2026-09-27 12:05 ` [RFC PATCH v4 3/7] mm/damon/sysfs-schemes: support quota goal complement flag SJ Park
2026-09-27 12:19 ` sashiko-bot
2026-09-27 12:31 ` SJ Park
2026-09-27 12:05 ` [RFC PATCH v4 4/7] mm/damon/tests/core-kunit: test quota_goal->complement commit SJ Park
2026-09-27 12:13 ` sashiko-bot
2026-09-27 12:05 ` [RFC PATCH v4 5/7] Docs/mm/damon/design: document damos quota goal complement flag SJ Park
2026-09-27 12:13 ` sashiko-bot
2026-09-27 12:35 ` SJ Park
2026-09-27 12:05 ` [RFC PATCH v4 6/7] Docs/admin-guide/mm/damon/usage: update for quota goal complement file SJ Park
2026-09-27 12:13 ` sashiko-bot
2026-09-27 12:36 ` SJ Park
2026-09-27 12:05 ` [RFC PATCH v4 7/7] Docs/ABI/damon: update for quota goal metric complement sysfs file SJ Park
2026-09-27 12:14 ` sashiko-bot
2026-09-27 12:37 ` SJ Park
2026-09-27 13:05 ` [RFC PATCH v4 0/7] mm/damon: introduce damos quota goal target metric complement flag (was: "Re: [RFC PATCH v4 0/7] snapshot_set_swap_area() unpins the previously selected swap device and") 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=20260927121715.19E841F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=damon@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@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