* FAILED: patch "[PATCH] mm/damon/core: move static variable last_nr_regions to damon_ctx" failed to apply to 6.12-stable tree
@ 2026-11-10 1:08 Sasha Levin
2026-11-10 2:29 ` [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx SJ Park
2026-11-10 15:02 ` [PATCH 6.12.y v2] " SJ Park
0 siblings, 2 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-10 1:08 UTC (permalink / raw)
To: sj, akpm, sieberf, sjpark; +Cc: stable
The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 26ae50a0901a44f7d50053f87dc38abd9f9a269c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '20261109200803-failed-6.12-26ae50a0901a@kernel.org' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 26ae50a0901a44f7d50053f87dc38abd9f9a269c Mon Sep 17 00:00:00 2001
From: SJ Park <sj@kernel.org>
Date: Sun, 25 Oct 2026 09:48:05 -0700
Subject: [PATCH] mm/damon/core: move static variable last_nr_regions to
damon_ctx
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(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 63050eb2206a0..cb6a50032a1eb 100644
--- a/include/linux/damon.h
+++ b/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. */
diff --git a/mm/damon/core.c b/mm/damon/core.c
index eb1fcdabc0075..09722257ce736 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3795,7 +3795,6 @@ static noinline_for_stack void kdamond_split_regions(struct damon_ctx *ctx)
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_split_regions(struct damon_ctx *ctx)
}
/* 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_split_regions(struct damon_ctx *ctx)
ctx->min_region_sz);
done:
- last_nr_regions = nr_regions;
+ ctx->last_nr_regions = nr_regions;
}
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx
2026-11-10 1:08 FAILED: patch "[PATCH] mm/damon/core: move static variable last_nr_regions to damon_ctx" failed to apply to 6.12-stable tree Sasha Levin
@ 2026-11-10 2:29 ` SJ Park
2026-11-10 2:35 ` sashiko-bot
2026-11-10 15:02 ` [PATCH 6.12.y v2] " SJ Park
1 sibling, 1 reply; 7+ messages in thread
From: SJ Park @ 2026-11-10 2:29 UTC (permalink / raw)
To: stable; +Cc: damon, SJ Park, Andrew Morton, Fernand Sieber, SeongJae Park
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
(cherry picked from commit 26ae50a0901a44f7d50053f87dc38abd9f9a269c)
Signed-off-by: SJ Park <sj@kernel.org>
---
include/linux/damon.h | 5 +++++
mm/damon/core.c | 5 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 4688a10eca89b..dfd0295104d37 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -641,6 +641,11 @@ struct damon_ctx {
struct list_head adaptive_targets;
struct list_head schemes;
+ /*
+ * number of regions after last merge. Read kdamond_split_regions()
+ * for more details.
+ */
+ unsigned long last_nr_regions;
};
static inline struct damon_region *damon_next_region(struct damon_region *r)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3142776e2e0ee..ec7f22ad33e1d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1932,7 +1932,6 @@ static void kdamond_split_regions(struct damon_ctx *ctx)
{
struct damon_target *t;
unsigned int nr_regions = 0;
- static unsigned int last_nr_regions;
int nr_subregions = 2;
damon_for_each_target(t, ctx)
@@ -1942,14 +1941,14 @@ static void kdamond_split_regions(struct damon_ctx *ctx)
return;
/* 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 < ctx->attrs.max_nr_regions / 3)
nr_subregions = 3;
damon_for_each_target(t, ctx)
damon_split_regions_of(t, nr_subregions);
- last_nr_regions = nr_regions;
+ ctx->last_nr_regions = nr_regions;
}
/*
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx
2026-11-10 2:29 ` [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx SJ Park
@ 2026-11-10 2:35 ` sashiko-bot
2026-11-10 2:46 ` SJ Park
0 siblings, 1 reply; 7+ messages in thread
From: sashiko-bot @ 2026-11-10 2:35 UTC (permalink / raw)
To: SJ Park; +Cc: damon
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm/damon: last_nr_regions placed in public section of struct
damon_ctx
--
commit eb0ad0bdecede5a2fbbdad016dac644dd4b389f4
Author: SJ Park <sj@kernel.org>
mm/damon/core: move static variable last_nr_regions to damon_ctx
This commit moves the static last_nr_regions variable from
kdamond_split_regions() into struct damon_ctx so parallel kdamond threads
do not race on region split state.
Link: https://lore.kernel.org/20261025164808.152048-3-sj@kernel.org
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index 4688a10eca89b..dfd0295104d37 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -641,6 +641,11 @@ struct damon_ctx {
>
> struct list_head adaptive_targets;
> struct list_head schemes;
> + /*
> + * number of regions after last merge. Read kdamond_split_regions()
> + * for more details.
> + */
> + unsigned long last_nr_regions;
> };
>
> static inline struct damon_region *damon_next_region(struct damon_region *r)
[Severity: Low]
Should last_nr_regions be placed inside the /* private: internal use only */
section of struct damon_ctx (or preceded by a /* private: */ marker)?
In this tree, the end of struct damon_ctx is after /* public: */, so adding
last_nr_regions here without a kernel-doc entry causes scripts/kernel-doc
(via Documentation/mm/damon/api.rst) to warn:
Function parameter or struct member 'last_nr_regions' not described in 'damon_ctx'
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110022924.115699-1-sj@kernel.org?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx
2026-11-10 2:35 ` sashiko-bot
@ 2026-11-10 2:46 ` SJ Park
0 siblings, 0 replies; 7+ messages in thread
From: SJ Park @ 2026-11-10 2:46 UTC (permalink / raw)
To: sashiko-bot; +Cc: SJ Park, damon
On Tue, 10 Nov 2026 02:35:53 +0000 sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] mm/damon: last_nr_regions placed in public section of struct
> damon_ctx
> --
>
> commit eb0ad0bdecede5a2fbbdad016dac644dd4b389f4
> Author: SJ Park <sj@kernel.org>
>
> mm/damon/core: move static variable last_nr_regions to damon_ctx
>
> This commit moves the static last_nr_regions variable from
> kdamond_split_regions() into struct damon_ctx so parallel kdamond threads
> do not race on region split state.
>
> Link: https://lore.kernel.org/20261025164808.152048-3-sj@kernel.org
>
> > diff --git a/include/linux/damon.h b/include/linux/damon.h
> > index 4688a10eca89b..dfd0295104d37 100644
> > --- a/include/linux/damon.h
> > +++ b/include/linux/damon.h
> > @@ -641,6 +641,11 @@ struct damon_ctx {
> >
> > struct list_head adaptive_targets;
> > struct list_head schemes;
> > + /*
> > + * number of regions after last merge. Read kdamond_split_regions()
> > + * for more details.
> > + */
> > + unsigned long last_nr_regions;
> > };
> >
> > static inline struct damon_region *damon_next_region(struct damon_region *r)
>
> [Severity: Low]
> Should last_nr_regions be placed inside the /* private: internal use only */
> section of struct damon_ctx (or preceded by a /* private: */ marker)?
>
> In this tree, the end of struct damon_ctx is after /* public: */, so adding
> last_nr_regions here without a kernel-doc entry causes scripts/kernel-doc
> (via Documentation/mm/damon/api.rst) to warn:
>
> Function parameter or struct member 'last_nr_regions' not described in 'damon_ctx'
Nice catch. I will post v2 with a fix for this.
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261110022924.115699-1-sj@kernel.org?part=1
>
Thanks,
SJ
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6.12.y v2] mm/damon/core: move static variable last_nr_regions to damon_ctx
2026-11-10 1:08 FAILED: patch "[PATCH] mm/damon/core: move static variable last_nr_regions to damon_ctx" failed to apply to 6.12-stable tree Sasha Levin
2026-11-10 2:29 ` [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx SJ Park
@ 2026-11-10 15:02 ` SJ Park
2026-11-10 15:04 ` sashiko-bot
2026-11-10 20:59 ` Sasha Levin
1 sibling, 2 replies; 7+ messages in thread
From: SJ Park @ 2026-11-10 15:02 UTC (permalink / raw)
To: stable; +Cc: SJ Park, Andrew Morton, Fernand Sieber, SeongJae Park, damon
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
(cherry picked from commit 26ae50a0901a44f7d50053f87dc38abd9f9a269c)
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20261110022924.115699-1-sj@kernel.org
- Mark last_nr_regions as a private field to avoid kernel-doc warning.
include/linux/damon.h | 6 ++++++
mm/damon/core.c | 5 ++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 4688a10eca89b..b05c626f6479a 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -641,6 +641,12 @@ struct damon_ctx {
struct list_head adaptive_targets;
struct list_head schemes;
+/* private: */
+ /*
+ * number of regions after last merge. Read kdamond_split_regions()
+ * for more details.
+ */
+ unsigned long last_nr_regions;
};
static inline struct damon_region *damon_next_region(struct damon_region *r)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3142776e2e0ee..ec7f22ad33e1d 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1932,7 +1932,6 @@ static void kdamond_split_regions(struct damon_ctx *ctx)
{
struct damon_target *t;
unsigned int nr_regions = 0;
- static unsigned int last_nr_regions;
int nr_subregions = 2;
damon_for_each_target(t, ctx)
@@ -1942,14 +1941,14 @@ static void kdamond_split_regions(struct damon_ctx *ctx)
return;
/* 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 < ctx->attrs.max_nr_regions / 3)
nr_subregions = 3;
damon_for_each_target(t, ctx)
damon_split_regions_of(t, nr_subregions);
- last_nr_regions = nr_regions;
+ ctx->last_nr_regions = nr_regions;
}
/*
base-commit: a100533c838bab5a555d92e082e38e092f2b4ea6
--
2.47.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 6.12.y v2] mm/damon/core: move static variable last_nr_regions to damon_ctx
2026-11-10 15:02 ` [PATCH 6.12.y v2] " SJ Park
@ 2026-11-10 15:04 ` sashiko-bot
2026-11-10 20:59 ` Sasha Levin
1 sibling, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-10 15:04 UTC (permalink / raw)
To: SJ Park; +Cc: damon
> 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
> (cherry picked from commit 26ae50a0901a44f7d50053f87dc38abd9f9a269c)
> Signed-off-by: SJ Park <sj@kernel.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110150218.145605-1-sj@kernel.org?part=1
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 6.12.y v2] mm/damon/core: move static variable last_nr_regions to damon_ctx
2026-11-10 15:02 ` [PATCH 6.12.y v2] " SJ Park
2026-11-10 15:04 ` sashiko-bot
@ 2026-11-10 20:59 ` Sasha Levin
1 sibling, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-10 20:59 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, SJ Park, Andrew Morton, Fernand Sieber,
SeongJae Park, damon
> mm/damon/core: move static variable last_nr_regions to damon_ctx
Queued for 6.18, 6.12, 6.6, 6.1 and 5.15, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-10 20:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 1:08 FAILED: patch "[PATCH] mm/damon/core: move static variable last_nr_regions to damon_ctx" failed to apply to 6.12-stable tree Sasha Levin
2026-11-10 2:29 ` [PATCH 6.12.y] mm/damon/core: move static variable last_nr_regions to damon_ctx SJ Park
2026-11-10 2:35 ` sashiko-bot
2026-11-10 2:46 ` SJ Park
2026-11-10 15:02 ` [PATCH 6.12.y v2] " SJ Park
2026-11-10 15:04 ` sashiko-bot
2026-11-10 20:59 ` Sasha Levin
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.