FAILED: patch "[PATCH] mm/damon/paddr: drop last same folio access check reuse" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-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 <[email protected]>.
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.18.y
git checkout FETCH_HEAD
git cherry-pick -x f23f0aa62b2f32c2b12f95959fc4603ef81678b2
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090852-ought-makeover-4182@gregkh' --subject-prefix 'PATCH 6.18.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 <[email protected]>
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.
mm/damon/paddr.c +4 -16
@@ -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)
SJ Park
maintainerPATCH 1/1 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.
--- mm/damon/paddr.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
mm/damon/paddr.c +4 -16
@@ -67,7 +67,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;
@@ -76,7 +76,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; }
@@ -84,23 +83,12 @@ static bool damon_pa_young(phys_addr_t paddr, unsigned long *folio_sz)static void __damon_pa_check_access (struct damon_region *r,struct damon_attrs *attrs,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, attrs); -return ; - } - - last_accessed =damon_pa_young (sampling_addr, &last_folio_sz); -damon_update_region_access_rate (r, last_accessed, attrs); - - last_addr = sampling_addr; + accessed =damon_pa_young (sampling_addr); +damon_update_region_access_rate (r, accessed, attrs); }static unsigned int damon_pa_check_accesses (struct damon_ctx *ctx)
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH 6.18.y] mm/damon/paddr: drop last same folio access check reuse optimization
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 12 lines
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.
Quoted 8 lines
Fixes a28397beb55b ("mm/damon: implement primitives for physical address space monitoring")Signed-off-by SJ Park <[email protected]>Cc <[email protected]> # 5.16.xSigned-off-by Andrew Morton <[email protected]>(cherry picked from commit f23f0aa62b2f32c2b12f95959fc4603ef81678b2)Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1