Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C4525437DF for ; Tue, 8 Sep 2026 12:58:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788872283; cv=none; b=NtE4E05256NaqAbVm0Py3SLneXK60pWSHymYN5NqJbfx0aeF2rb2YsAv57s0Zcd6Rz/RcGKG83ZZHqZ8UtVj1EG2WTXCONCn8NkL2h6VV5G+ckCQN53AaW+g1yS/A2c1hMxAmKdMi8qlvSykEP1bbR8vtF4SfdPD6eTd2rU7xLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788872283; c=relaxed/simple; bh=kB80SV3dhlIqZqLKxqTEPi/JFHdRALByokCt/JtV6hg=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=UX905MH7tsDluXV3eXfCXSzK1mG/cC0Vw5rQ9II9VDuSrVTlWc2MATEi4sV+VcVn7d8p6y5c5MbqUVI0VLosrqWrR2vyIr4QhhoB+IgQR6Xk51SJl8MTt5+MHX/NoAJ3vCSzOrd9a5MJrBp367hm/IFrY6YKJvIVLFoPTVTs+gg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mtUnL/Zc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="mtUnL/Zc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BABE1F00A3D; Tue, 8 Sep 2026 12:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788872281; bh=nk3CUOvkdHy9cex96aDY1+FYa+RQlUKKWjEXsd3JJLw=; h=Subject:To:Cc:From:Date; b=mtUnL/ZcEnpndTwSXkM2Jag+PyXc8LdbbIbF7mghUl4ZF7VHVBWWy3YYw226yvg0R n4ICnrRi7rjtCPMiUSfo1si7xvqSL6h1/9cTAfHdc1Qf99cSnSizhIh+2FJ7wVuZjA GloAEzogh7yDhvVVGnlO1MVX5A/Ctne0wocuzcWQ= Subject: FAILED: patch "[PATCH] mm/damon/paddr: drop last same folio access check reuse" failed to apply to 6.12-stable tree To: sj@kernel.org,akpm@linux-foundation.org,stable@vger.kernel.org Cc: From: Date: Tue, 08 Sep 2026 14:52:52 +0200 Message-ID: <2026090852-morally-preview-efa5@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit 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 . 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 f23f0aa62b2f32c2b12f95959fc4603ef81678b2 # git commit -s git send-email --to '' --in-reply-to '2026090852-morally-preview-efa5@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From f23f0aa62b2f32c2b12f95959fc4603ef81678b2 Mon Sep 17 00:00:00 2001 From: SJ Park Date: Tue, 14 Jul 2026 20:09:59 -0700 Subject: [PATCH] mm/damon/paddr: drop last same folio access check reuse optimization It can race when multiple kdamonds are being used. The problem from the race is doubtful, but the gain from the optimization is also doubtful. Simply drop the optimization in favor of code simplicity. The user impact is doubtfully trivial. After all, this kind of interference can happen only by intentional user setup. Even if it happens, it will be rare, and the consequence is degradation of the best-effort monitoring results. No critical consequences like kernel panic or memory corruption happen. The race was discovered [1] by Sashiko. Link: https://lore.kernel.org/20260715031002.108504-5-sj@kernel.org Link: https://lore.kernel.org/20260621204050.10993-1-sj@kernel.org [1] Fixes: a28397beb55b ("mm/damon: implement primitives for physical address space monitoring") Signed-off-by: SJ Park Cc: # 5.16.x Signed-off-by: Andrew Morton diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index b85f88a7a38f..e4f98d67461f 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -65,7 +65,7 @@ static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) } } -static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz) +static bool damon_pa_young(phys_addr_t paddr) { struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); bool accessed; @@ -74,7 +74,6 @@ static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz) return false; accessed = damon_folio_young(folio); - *folio_sz = folio_size(folio); folio_put(folio); return accessed; } @@ -82,23 +81,12 @@ static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz) static void __damon_pa_check_access(struct damon_region *r, unsigned long addr_unit) { - static phys_addr_t last_addr; - static unsigned long last_folio_sz = PAGE_SIZE; - static bool last_accessed; + bool accessed; phys_addr_t sampling_addr = damon_pa_phys_addr( r->sampling_addr, addr_unit); - /* If the region is in the last checked page, reuse the result */ - if (ALIGN_DOWN(last_addr, last_folio_sz) == - ALIGN_DOWN(sampling_addr, last_folio_sz)) { - damon_update_region_access_rate(r, last_accessed); - return; - } - - last_accessed = damon_pa_young(sampling_addr, &last_folio_sz); - damon_update_region_access_rate(r, last_accessed); - - last_addr = sampling_addr; + accessed = damon_pa_young(sampling_addr); + damon_update_region_access_rate(r, accessed); } static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx)