* + mm-damon-core-move-static-variable-rotation-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, jiayuan.chen, sj, akpm
The patch titled
Subject: mm/damon/core: move static variable rotation to damon_ctx
has been added to the -mm mm-unstable branch. Its filename is
mm-damon-core-move-static-variable-rotation-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-rotation-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 rotation to damon_ctx
Date: Sun, 25 Oct 2026 09:48:06 -0700
damon_split_some_reigons() uses a static variable, rotation, to remember
how many times it was called. It is again used to determine fair
selection of regions to split. Since it is a static variable, it can be
indeterministic and therefore less fair.
The user impact is not critical. No crash, no leak. DAMON's
best-effort and indeterministic monitoring accuracy could be slightly
more indeterministic when multiple kdamonds are used in parallel.
Fix the problem by moving the static variable into the damon_ctx struct.
Link: https://lore.kernel.org/20261025164808.152048-4-sj@kernel.org
Fixes: 1a582e6e0174 ("mm/damon/core: split a fraction of regions when nr_regions exceeds max/2")
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: Jiayuan Chen <jiayuan.chen@shopee.com>
Cc: <stable@vger.kernel.org> # 7.3.x
---
include/linux/damon.h | 5 +++++
mm/damon/core.c | 5 +++--
2 files changed, 8 insertions(+), 2 deletions(-)
--- a/include/linux/damon.h~mm-damon-core-move-static-variable-rotation-to-damon_ctx
+++ a/include/linux/damon.h
@@ -963,6 +963,11 @@ struct damon_ctx {
* for more details.
*/
unsigned long last_nr_regions;
+ /*
+ * number of damon_split_some_regions() invocations for this context.
+ * Read damon_split_some_regions() for more details.
+ */
+ unsigned long region_split_rotation;
};
/* Get a random number in [@l, @r) using @ctx's lockless PRNG. */
--- a/mm/damon/core.c~mm-damon-core-move-static-variable-rotation-to-damon_ctx
+++ a/mm/damon/core.c
@@ -3753,12 +3753,13 @@ static void damon_split_regions_of(struc
static void damon_split_some_regions(struct damon_ctx *ctx,
unsigned long split_step)
{
- static unsigned long rotation;
struct damon_target *t;
struct damon_region *r, *next;
- unsigned long offset = rotation++ % split_step;
+ unsigned long offset;
unsigned long idx = 0;
+ offset = ctx->region_split_rotation++ % split_step;
+
damon_for_each_target(t, ctx) {
damon_for_each_region_safe(r, next, t) {
unsigned long sz_region, sz_sub;
_
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-rotation-to-damon_ctx.patch added to mm-unstable branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox