From: sashiko-bot@kernel.org
To: "SJ Park" <sj@kernel.org>
Cc: damon@lists.linux.dev
Subject: Re: [PATCH 6.6.y] mm/damon/core: skip aging from repeated aggressive merging
Date: Wed, 09 Sep 2026 04:57:00 +0000 [thread overview]
Message-ID: <20260909045700.72B591F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909044707.221421-1-sj@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Infinite loop in `kdamond_merge_regions` when `max_thres` > 2^30 due to `unsigned int` overflow.
--
commit 2beb7e632c69db2ccfb8ea5cced50b76ca2b931f
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 repeatedly merging
regions aggressively. It prevents corrupting monitoring results when the user
temporarily lowers the maximum number of regions limit.
Link: https://lore.kernel.org/20260712165432.87609-1-sj@kernel.org
Link: https://lore.kernel.org/20260621203548.10718-1-sj@kernel.org [1]
Link: https://lore.kernel.org/20260709145425.96247-1-sj@kernel.org [2]
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 734ab958ec576..0713fda22682c 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -1234,15 +1236,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);
> + damon_merge_regions_of(t, threshold, sz_limit,
> + 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 isn't a bug introduced by this patch, but could this lead to an
infinite loop if max_thres is sufficiently large?
If a user configures DAMON parameters such that the aggregation interval
divided by the sample interval results in a max_thres greater than 2^30,
threshold (an unsigned int) will strictly double each iteration. Once
threshold reaches 2^31, threshold * 2 wraps around to 0, which max() sets
to 1.
At that point, threshold / 2 becomes 0, and the loop condition
threshold / 2 < max_thres will permanently evaluate to true, causing an
unrecoverable hang of the kdamond kernel thread if the region limit is
not met.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909044707.221421-1-sj@kernel.org?part=1
next prev parent reply other threads:[~2026-09-09 4:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026090841-dingo-oxygen-6b88@gregkh>
2026-09-09 4:47 ` [PATCH 6.6.y] mm/damon/core: skip aging from repeated aggressive merging SJ Park
2026-09-09 4:57 ` sashiko-bot [this message]
2026-09-11 11:20 ` Sasha Levin
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=20260909045700.72B591F00A3A@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