From: Greg KH <greg@kroah.com>
To: SJ Park <sj@kernel.org>
Cc: stable@vger.kernel.org, damon@lists.linux.dev,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 7.2.y] mm/damon/core: skip aging from repeated aggressive merging
Date: Wed, 9 Sep 2026 14:19:27 +0200 [thread overview]
Message-ID: <2026090918-relic-padded-3b25@gregkh> (raw)
In-Reply-To: <20260909043419.207354-1-sj@kernel.org>
On Tue, Sep 08, 2026 at 09:34:19PM -0700, SJ Park wrote:
> The number of DAMON regions could temporarily exceed the user-defined
> maximum number of regions limit for corner cases. For example, users
> could lower the limit via runtime parameters update. For such a case,
> kdamond_merge_regions() repeats merging regions in the case doubling the
> merge threshold. The repeated merge operation could update the age of
> regions multiple times. This corrupts the monitoring results. Fix the
> issue by asking the merge operation to skip aging for the corner case.
>
> The user impact is degradation of the monitoring quality. The impact
> should be mild, since the degradation is only temporal, and it is not
> common to happen in realistic setups.
>
> The issue was discovered [1,2] by Sashiko.
>
> 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]
> Fixes: 310d6c15e910 ("mm/damon/core: merge regions aggressively when max_nr_regions is unmet")
> Signed-off-by: SJ Park <sj@kernel.org>
> Cc: <stable@vger.kernel.org> # 6.10
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit 0250dbe08c730d003ef9f484da56ae09a1ea0c4c)
> Signed-off-by: SJ Park <sj@kernel.org>
> ---
> mm/damon/core.c | 21 +++++++++++++--------
> mm/damon/tests/core-kunit.h | 2 +-
> 2 files changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index cff932b3317d0..024a3a185bfe8 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
> @@ -3115,18 +3115,20 @@ static void damon_verify_merge_regions_of(struct damon_region *r)
> * sz_limit size upper limit of each region
> */
> static void damon_merge_regions_of(struct damon_target *t, unsigned int thres,
> - unsigned long sz_limit)
> + unsigned long sz_limit, bool count_age)
> {
> struct damon_region *r, *prev = NULL, *next;
>
> damon_for_each_region_safe(r, next, t) {
> damon_verify_merge_regions_of(r);
> - if (abs(r->nr_accesses - r->last_nr_accesses) > thres)
> - r->age = 0;
> - else if ((r->nr_accesses == 0) != (r->last_nr_accesses == 0))
> - r->age = 0;
> - else
> - r->age++;
> + if (count_age) {
> + if (abs(r->nr_accesses - r->last_nr_accesses) > thres)
> + r->age = 0;
> + else if ((r->nr_accesses == 0) != (r->last_nr_accesses == 0))
> + r->age = 0;
> + else
> + r->age++;
> + }
>
> if (prev && prev->ar.end == r->ar.start &&
> abs(prev->nr_accesses - r->nr_accesses) <= thres &&
> @@ -3160,15 +3162,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);
> diff --git a/mm/damon/tests/core-kunit.h b/mm/damon/tests/core-kunit.h
> index fcf7c7fadb5fe..59bba0552d88c 100644
> --- a/mm/damon/tests/core-kunit.h
> +++ b/mm/damon/tests/core-kunit.h
> @@ -256,7 +256,7 @@ static void damon_test_merge_regions_of(struct kunit *test)
> damon_add_region(r, t);
> }
>
> - damon_merge_regions_of(t, 9, 9999);
> + damon_merge_regions_of(t, 9, 9999, true);
> /* 0-112, 114-130, 130-156, 156-170, 170-230, 230-10170 */
> KUNIT_EXPECT_EQ(test, damon_nr_regions(t), 6u);
> for (i = 0; i < 6; i++) {
> --
> 2.47.3
>
>
Does not apply to the latest 7.2.y queue :(
next prev parent reply other threads:[~2026-09-09 12:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026090839-reoccupy-dizzy-a7bd@gregkh>
2026-09-09 4:34 ` [PATCH 7.2.y] mm/damon/core: skip aging from repeated aggressive merging SJ Park
2026-09-09 4:49 ` sashiko-bot
2026-09-09 12:19 ` Greg KH [this message]
2026-09-10 1:02 ` SJ Park
2026-09-10 6:15 ` Greg KH
2026-09-10 0:52 ` 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=2026090918-relic-padded-3b25@gregkh \
--to=greg@kroah.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=sj@kernel.org \
--cc=stable@vger.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.