From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [RFC PATCH v1.2 2/4] mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
Date: Fri, 28 Aug 2026 01:55:23 +0000 [thread overview]
Message-ID: <20260828015524.5F0AA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828014659.121058-3-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Integer underflow when initializing last_psi_total causes severe quota throttling instead of maintaining the quota.
--
commit 216061cc4d3a0304d1961ab1798b65cbf748aa6c
Author: SJ Park <sj@kernel.org>
mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total
This commit handles an uninitialized last_psi_total for PSI metric DAMOS
quota goals by initializing it to U64_MAX. During the first tuning round,
it detects this state and attempts to set last_psi_total such that the
first iteration has no unexpected effect on the quota.
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 644daf5a16560..b0c8e22ab5404 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -3018,6 +3022,10 @@ static void damos_set_quota_goal_current_value(struct damon_ctx *c,
> break;
> case DAMOS_QUOTA_SOME_MEM_PSI_US:
> now_psi_total = damos_get_some_mem_psi_total();
> + /* uninitialized last_psi_total; make no effect this round */
> + if (goal->last_psi_total == U64_MAX)
> + goal->last_psi_total = now_psi_total +
> + goal->target_value;
> goal->current_value = now_psi_total - goal->last_psi_total;
[Severity: High]
Does this arithmetic result in an integer underflow on the first tuning
round?
If goal->last_psi_total is set to (now_psi_total + goal->target_value), the
calculation on the very next line becomes:
goal->current_value = now_psi_total - (now_psi_total + goal->target_value)
This evaluates to -goal->target_value. Since current_value is an unsigned
long, this underflows to an astronomically large value. Will the feedback
loop interpret this as a massive over-achievement and drastically throttle
the quota to its minimum, causing the exact opposite of the intended
"no effect this round" behavior?
> goal->last_psi_total = now_psi_total;
> break;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828014659.121058-1-sj@kernel.org?part=2
next prev parent reply other threads:[~2026-08-28 1:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 1:46 [RFC PATCH v1.2 0/4] mm/damon: fix misc bugs in kunit, quota goals and sysfs refresh_ms SJ Park
2026-08-28 1:46 ` [RFC PATCH v1.2 1/4] mm/damon/tests/core-kunit: test committing psi goal to psi goal SJ Park
2026-08-28 1:54 ` sashiko-bot
2026-08-28 1:46 ` [RFC PATCH v1.2 2/4] mm/damon/core: handle uninitialized damos_quota_goal->last_psi_total SJ Park
2026-08-28 1:55 ` sashiko-bot [this message]
2026-08-28 2:22 ` SJ Park
2026-08-28 1:46 ` [RFC PATCH v1.2 3/4] mm/damon/core: copy nid for eligible_mem_bp damos quota goal commit SJ Park
2026-08-28 1:56 ` sashiko-bot
2026-08-28 2:23 ` SJ Park
2026-08-28 1:46 ` [RFC PATCH v1.2 4/4] mm/damon/sysfs: set next refresh jiffies per sysfs context SJ Park
2026-08-28 1:57 ` 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=20260828015524.5F0AA1F000E9@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 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.