From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Brendan Higgins" <brendan.higgins@linux.dev>,
"David Gow" <davidgow@davidgow.net>,
"Quanmin Yan" <yanquanmin1@huawei.com>,
damon@lists.linux.dev, linux-mm@kvack.org,
"Lian Wang" <lianux.mm@gmail.com>,
"Kunwu Chan" <kunwu.chan@gmail.com>
Subject: Re: [PATCH 6.12.y 3/5] mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
Date: Sun, 08 Nov 2026 20:03:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-204001@kernel.org> (raw)
In-Reply-To: <20261108195145.115792-4-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/damon: integer overflow in damos_quota_score() on first
PSI round
--
commit 6456f90a0b14251a6d548d6849beb9dd850f55e6
Author: SJ Park <sj@kernel.org>
mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
This commit initializes damos_quota_goal->last_psi_total to U64_MAX upon
creation and commit, and sets goal->current_value to goal->target_value on
the first PSI tuning round so the effective quota remains unchanged until
a baseline PSI reading is recorded.
Link: https://lore.kernel.org/20260902002725.108635-3-sj@kernel.org
Link: https://lore.kernel.org/20260718005316.89585-1-sj@kernel.org [1]
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 6ef77741b783b..52f01a6508b66 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -1608,7 +1611,12 @@ static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal)
> break;
> case DAMOS_QUOTA_SOME_MEM_PSI_US:
> now_psi_total = damos_get_some_mem_psi_total();
> - goal->current_value = now_psi_total - goal->last_psi_total;
> + /* uninitialized last_psi_total; make no effect this round */
> + if (goal->last_psi_total == U64_MAX)
> + goal->current_value = goal->target_value;
> + else
> + goal->current_value = now_psi_total -
> + goal->last_psi_total;
> goal->last_psi_total = now_psi_total;
> break;
> default:
[Severity: Medium]
Can setting goal->current_value to goal->target_value overflow in
damos_quota_score() when goal->target_value exceeds ULONG_MAX / 10000?
Unlike mainline where damos_quota_score() uses mult_frac(), this tree
computes the score with unsigned long multiplication:
mm/damon/core.c:damos_quota_score() {
damos_for_each_quota_goal(goal, quota) {
damos_set_quota_goal_current_value(goal);
highest_score = max(highest_score,
goal->current_value * 10000 /
goal->target_value);
}
}
When goal->target_value > ULONG_MAX / 10000 (for example, above 429,496 us
on 32-bit architectures), goal->current_value * 10000 wraps around and
produces a score below 10000, causing damon_feed_loop_next_input() to
increase the effective quota on the first round instead of keeping it
unchanged.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108195145.115792-1-sj@kernel.org?part=3
next prev parent reply other threads:[~2026-11-08 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 19:51 [PATCH 6.12.y 0/5] mm/damon: porting fixes that cherry-pick failed on 2026-11-07 SJ Park
2026-11-08 19:51 ` [PATCH 6.12.y 1/5] mm/damon/core: skip applying scheme if region split for quota fails SJ Park
2026-11-08 20:00 ` sashiko-bot
2026-11-08 20:07 ` SJ Park
2026-11-08 19:51 ` [PATCH 6.12.y 2/5] mm/damon/paddr: respect folio end for DAMOS actions except STAT SJ Park
2026-11-08 19:51 ` [PATCH 6.12.y 3/5] mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total SJ Park
2026-11-08 20:03 ` sashiko-bot [this message]
2026-11-08 20:13 ` SJ Park
2026-11-08 19:51 ` [PATCH 6.12.y 4/5] mm/damon/core: filter out damos address filter-split failed region SJ Park
2026-11-08 19:51 ` [PATCH 6.12.y 5/5] mm/damon/core: remove unreachable damos charge_{target,addr}_from 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=sashiko-outbox-204001@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brendan.higgins@linux.dev \
--cc=damon@lists.linux.dev \
--cc=davidgow@davidgow.net \
--cc=kunwu.chan@gmail.com \
--cc=lianux.mm@gmail.com \
--cc=linux-mm@kvack.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sj@kernel.org \
--cc=yanquanmin1@huawei.com \
/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