* + mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx.patch added to mm-unstable branch
@ 2026-10-25 16:54 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-25 16:54 UTC (permalink / raw)
To: mm-commits, stable, sjpark, sieberf, sj, akpm
The patch titled
Subject: mm/damon/core: move static variable last_nr_regions to damon_ctx
has been added to the -mm mm-unstable branch. Its filename is
mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: SJ Park <sj@kernel.org>
Subject: mm/damon/core: move static variable last_nr_regions to damon_ctx
Date: Sun, 25 Oct 2026 09:48:05 -0700
kdamond_split_regions() uses a static variable last_nr_regions, to infer
if the region boundaries are too stable. If it looks too stable, it
does a more aggressive region split because it might be a fake stability
coming from non-aggressive split. Because the variable is static, the
inference can be racy and wrong when multiple kdamonds are running in
parallel.
The user impact is not critical. No crash, no leak. DAMON's
best-effort monitoring accuracy can be degraded when multiple kdamonds
are used in parallel and the workload has certain access patterns. Still
it is a bug that is better to fix.
Move the variable into the damon_ctx struct to fix the problem.
Link: https://lore.kernel.org/20261025164808.152048-3-sj@kernel.org
Fixes: 75c1c2b53c78 ("mm/damon/dbgfs: support multiple contexts")
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Closes: https://sashiko.dev/#/bug/linux-eebfcdde-2881-48ef-8df1-e2019d2a47f2
Cc: Fernand Sieber <sieberf@amazon.com>
Cc: SeongJae Park <sjpark@amazon.de>
Cc: <stable@vger.kernel.org> # 5.15.x
---
include/linux/damon.h | 5 +++++
mm/damon/core.c | 5 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
--- a/include/linux/damon.h~mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx
+++ a/include/linux/damon.h
@@ -958,6 +958,11 @@ struct damon_ctx {
/* @rnd_state: Per-ctx PRNG state for damon_rand(). */
struct rnd_state rnd_state;
+ /*
+ * number of regions after last merge. Read kdamond_split_regions()
+ * for more details.
+ */
+ unsigned long last_nr_regions;
};
/* Get a random number in [@l, @r) using @ctx's lockless PRNG. */
--- a/mm/damon/core.c~mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx
+++ a/mm/damon/core.c
@@ -3795,7 +3795,6 @@ static noinline_for_stack void kdamond_s
struct damon_target *t;
unsigned long nr_regions = 0;
unsigned long max_nr_regions = ctx->attrs.max_nr_regions;
- static unsigned long last_nr_regions;
int nr_subregions = 2;
damon_for_each_target(t, ctx)
@@ -3811,7 +3810,7 @@ static noinline_for_stack void kdamond_s
}
/* Maybe the middle of the region has different access frequency */
- if (last_nr_regions == nr_regions &&
+ if (ctx->last_nr_regions == nr_regions &&
nr_regions < max_nr_regions / 3)
nr_subregions = 3;
@@ -3820,7 +3819,7 @@ static noinline_for_stack void kdamond_s
ctx->min_region_sz);
done:
- last_nr_regions = nr_regions;
+ ctx->last_nr_regions = nr_regions;
}
/*
_
Patches currently in -mm which might be from sj@kernel.org are
mm-damon-sysfs-schemes-hold-damon_sysfs_lock-in-target_metric_store.patch
mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx.patch
mm-damon-core-move-static-variable-rotation-to-damon_ctx.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-25 16:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-25 16:54 + mm-damon-core-move-static-variable-last_nr_regions-to-damon_ctx.patch added to mm-unstable branch Andrew Morton
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.