From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794273427; b=DKCcKeYq8RZTqe9dXnOh766MyI4JbVe5vAa2oJrz5LqyqanANSRsUlyRBvO+ooOJ9cFn TQYkw0lkMtzlGk+djBSXpX+qoqqfTYq5qOmzx5mPYRBOZu7n6SYu1a99RKvYBKtgoMCmB gJilk69rPIGpchn3JayXUydWHygXeup7OxAVYxfIrctggTA3wh0pHx+BEsw3FjtHJGLxB 8KzlEKk8hsPoLiUONbTHs1HXUOSlXUFXVYeVCUXGRNg15BMocgIK1aheoglelQDAy6w26 fkkR9KBI98BfT3I2qNhxpjOfJ3cxYph+MK5EsmuHveW0NSTcSQkYUhr2a3LuDgwE59g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794273427; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=BT6PmpylkZVVJuerBquTDxUUH3EMkMRehNImVBIPImk=; b=yUh3Bi9zwQlbqGqWDf1EcV7HLkvUtZes/phNeMXiUAQ+6zNA4h4jxqNvfCiKN4W7nihW qEbZA799F08LsNpFTYb2rs/kxPJQ1i4c4TUuC1ptdrqvJ5Aw9viIa5c7L6rvPw/pv4ArU xR0AiI0njAH9bQjoV2/+HnOnj/9e79Q1zRrOkugU80aGOMyqFcpQSmT2Fi9XrTh+miPoh NpPqyO7vayKDoYHmmklUyBTviJPhgBaBybxvkpL1ea4bKCMPv4f28b+8n9zHEyrZ+X/2C 2s1eXaoUTWuQRhxlkiM76J2Ya20IeuuLEDGewEI6eEF8E3yc5IqxFX8B03gVc0As4kw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="G5MOLZ/O"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59CA9606A31C for ; Tue, 10 Nov 2026 01:17:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=G5MOLZ/O Received: by smtp.kernel.org (Postfix) with ESMTPSA id 904731F0089F; Tue, 10 Nov 2026 01:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794273427; bh=BT6PmpylkZVVJuerBquTDxUUH3EMkMRehNImVBIPImk=; h=From:To:Cc:Subject:Date; b=G5MOLZ/OQ5QcroQOLv8A9feUYmhIEwL70JJQYkpka8Y3FqdOuLOPX5qORq7SqV+Lc RVDJdwrT5nggIQdT2P57ju45BQAa1sHtUCETJbvi6AbTvglDtd/8JwT/bPI8v4GJTH dze2XqOV+XKBOpibKmAY6sooPbpbQX9mYlvMj87j+eny0pAwUjtHgDmcqtpwY4My/m xdmt0VB9klsn+lv3kklixAtHHx6h7d0lwOzTWo/kU9nS/i8overNwaSqedT+KHycPE DiawvxOwmgBPrBX2YHFHrPFaAksn8R4L64bTiDk2ZIjKkU8g+evhqBfk4Z+klHUpaf WTDzFTQtGObOQ== From: Sasha Levin To: sj@kernel.org, akpm@linux-foundation.org, sieberf@amazon.com, sjpark@amazon.de Cc: stable@vger.kernel.org Subject: FAILED: patch "[PATCH] mm/damon/core: move static variable last_nr_regions to damon_ctx" failed to apply to 6.1-stable tree Date: Mon, 9 Nov 2026 20:17:05 -0500 Message-ID: <20261109201705-failed-6.1-26ae50a0901a@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-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 . 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.1.y git checkout FETCH_HEAD git cherry-pick -x 26ae50a0901a44f7d50053f87dc38abd9f9a269c # git commit -s git send-email --to '' --in-reply-to '20261109201705-failed-6.1-26ae50a0901a@kernel.org' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Thanks, Sasha ------------------ original commit in Linus's tree ------------------ >From 26ae50a0901a44f7d50053f87dc38abd9f9a269c Mon Sep 17 00:00:00 2001 From: SJ Park 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 Signed-off-by: Andrew Morton Closes: https://sashiko.dev/#/bug/linux-eebfcdde-2881-48ef-8df1-e2019d2a47f2 Cc: Fernand Sieber Cc: SeongJae Park Cc: # 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