From: SJ Park <sj@kernel.org>
To: sashiko-bot@kernel.org
Cc: SJ Park <sj@kernel.org>,
gutierrez.asier@huawei-partners.com, damon@lists.linux.dev
Subject: Re: [PATCH v3 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric
Date: Mon, 20 Jul 2026 20:50:23 -0700 [thread overview]
Message-ID: <20260721035025.147141-1-sj@kernel.org> (raw)
In-Reply-To: <20260720121538.9C1381F00ADF@smtp.kernel.org>
On Mon, 20 Jul 2026 12:15:38 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
> - [High] Integer underflow when computing 'total' in `damos_hugepage_mem_bp` causes DAMON to become maximally aggressive on highly idle systems.
> - [Medium] The new `hugepage_mem_bp` sysfs metric is missing from the DAMON sysfs selftest script.
> - [Low] Missing documentation for the `hugepage_mem_bp` metric in the DAMON design guide.
> --
>
> --- Patch [2]: [PATCH v3 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric ---
> commit 304fd61bee6da0356569e9c8297451d15a43e10f
> Author: Asier Gutierrez <gutierrez.asier@huawei-partners.com>
>
> mm/damon/sysfs: support hugepage_mem_bp quota goal metric
>
> This commit exposes the new DAMOS_QUOTA_HUGEPAGE_MEM_BP autotune policy
> metric through the DAMON sysfs interface. It adds "hugepage_mem_bp" to
> the sysfs-schemes interface.
>
> > diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> > index 32f495a96b17a..d9b81d7b5910e 100644
> > --- a/mm/damon/sysfs-schemes.c
> > +++ b/mm/damon/sysfs-schemes.c
> > @@ -1269,6 +1269,10 @@ struct damos_sysfs_qgoal_metric_name damos_sysfs_qgoal_metric_names[] = {
> > .metric = DAMOS_QUOTA_NODE_ELIGIBLE_MEM_BP,
> > .name = "node_eligible_mem_bp",
> > },
> > + {
> > + .metric = DAMOS_QUOTA_HUGEPAGE_MEM_BP,
> > + .name = "hugepage_mem_bp",
> > + },
> > };
>
> [Severity: High]
> While this patch exposes the new metric, is there a potential integer
> underflow in the underlying implementation of damos_hugepage_mem_bp() in
> mm/damon/core.c?
>
> Due to per-CPU vmstat counter drift, pending positive deltas from freed
> memory can cause the global NR_FREE_PAGES count to temporarily exceed the
> fixed totalram_pages(). In damos_hugepage_mem_bp(), total is computed as:
>
> total = totalram_pages() - global_zone_page_state(NR_FREE_PAGES);
>
> On a highly idle system, this could cause the unsigned subtraction to
> underflow, resulting in a value near ULONG_MAX. The subsequent !total check
> would fail, and mult_frac(thp, 10000, total) would evaluate to 0 due to the
> enormous denominator.
>
> Would this score of 0 lead damon_feed_loop_next_input() to perceive a maximal
> divergence from the goal, forcing the scheme to maximize its quota
> aggressiveness instead of minimizing it?
As I replied to the same report, the user impact is trivial. No blocker.
>
> [Severity: Medium]
> Should tools/testing/selftests/damon/sysfs.sh be updated to include the new
> metric?
>
> The test_goal() function validates writes to target_metric for all existing
> metrics:
>
> ensure_write_succ "$fpath" "active_mem_bp" "valid input"
> ensure_write_succ "$fpath" "inactive_mem_bp" "valid input"
> ensure_write_succ "$fpath" "node_eligible_mem_bp" "valid input"
>
> Could hugepage_mem_bp be added to this sequence to ensure the sysfs interface
> is regression tested?
Definitely better to do this. No blocker, though. I will do this unless
someone steps up earlier.
>
> [Severity: Low]
> Does this new metric need to be documented in
> Documentation/mm/damon/design.rst?
>
> The documentation lists all available target_metric values, such as
> inactive_mem_bp and node_eligible_mem_bp, but it appears hugepage_mem_bp
> is missing.
No blocker. The next patch of this series does that.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260720120140.881468-1-gutierrez.asier@huawei-partners.com?part=2
>
Thanks,
SJ
next prev parent reply other threads:[~2026-07-21 3:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 12:01 [PATCH v3 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning gutierrez.asier
2026-07-20 12:01 ` [PATCH v3 1/3] mm/damon: Introduce DAMOS_QUOTA_HUGEPAGE " gutierrez.asier
2026-07-20 12:16 ` sashiko-bot
2026-07-21 3:47 ` SJ Park
2026-07-20 12:01 ` [PATCH v3 2/3] mm/damon/sysfs: support hugepage_mem_bp quota goal metric gutierrez.asier
2026-07-20 12:15 ` sashiko-bot
2026-07-21 3:50 ` SJ Park [this message]
2026-07-20 12:01 ` [PATCH v3 3/3] Docs/mm/damon/design: Document hugepage_mem_bp target metric gutierrez.asier
2026-07-20 12:17 ` sashiko-bot
2026-07-21 3:52 ` SJ Park
2026-07-21 3:58 ` [PATCH v3 0/3] mm/damon: Introduce a huge page collapsing mechanism using auto tuning SJ Park
2026-07-21 12:58 ` Gutierrez Asier
2026-07-21 14:03 ` 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=20260721035025.147141-1-sj@kernel.org \
--to=sj@kernel.org \
--cc=damon@lists.linux.dev \
--cc=gutierrez.asier@huawei-partners.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox