From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH] mm/damon/core: skip aging from repeated aggressive merging
Date: Sun, 12 Jul 2026 17:10:20 +0000 [thread overview]
Message-ID: <20260712171021.D10321F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260712165432.87609-1-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] `kdamond_merge_regions()` can fall into an infinite loop due to integer overflow of `threshold`.
--
--- Patch [1]: [PATCH] mm/damon/core: skip aging from repeated aggressive merging ---
commit 1fa7392cc3fc19083e90cfb01dcfa4f03ebbc373
Author: SJ Park <sj@kernel.org>
mm/damon/core: skip aging from repeated aggressive merging
This commit modifies the DAMON core to skip aging when repeating region
merges during corner cases where the number of regions exceeds the
user-defined maximum limit. This prevents temporary degradation of
monitoring quality caused by updating region ages multiple times during
repeated merge operations.
Link: https://lore.kernel.org/20260621203548.10718-1-sj@kernel.org
Link: https://lore.kernel.org/20260709145425.96247-1-sj@kernel.org
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -3366,15 +3368,18 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold,
> struct damon_target *t;
> unsigned int nr_regions;
> unsigned int max_thres;
> + bool count_age = true;
>
> max_thres = c->attrs.aggr_interval /
> (c->attrs.sample_interval ? c->attrs.sample_interval : 1);
> do {
> nr_regions = 0;
> damon_for_each_target(t, c) {
> - damon_merge_regions_of(t, threshold, sz_limit, c);
> + damon_merge_regions_of(t, threshold, sz_limit, c,
> + count_age);
> nr_regions += damon_nr_regions(t);
> }
> + count_age = false;
> threshold = max(1, threshold * 2);
> } while (nr_regions > c->attrs.max_nr_regions &&
> threshold / 2 < max_thres);
[Severity: High]
This is a pre-existing issue, but can kdamond_merge_regions() fall into an
infinite loop under certain configurations?
If a user configures aggr_interval and sample_interval such that their
quotient (max_thres) exceeds 0x40000000, threshold could overflow in the
max() assignment above.
Since threshold is an unsigned int, doubling it once it reaches 0x80000000
causes an overflow to 0, which max(1, 0) clamps back to 1.
If regions cannot be merged further due to the sz_limit constraint,
nr_regions > c->attrs.max_nr_regions remains true indefinitely.
Because threshold cycles and never exceeds 0xFFFFFFFF, threshold / 2 never
reaches max_thres, causing this loop condition to evaluate to true endlessly.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260712165432.87609-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-07-12 17:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 16:54 [PATCH] mm/damon/core: skip aging from repeated aggressive merging SJ Park
2026-07-12 17:10 ` sashiko-bot [this message]
2026-07-12 17:22 ` SJ Park
2026-07-12 17:23 ` 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=20260712171021.D10321F000E9@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.