FAILED: patch "[PATCH] mm/damon/ops-common: call folio_test_lru() after folio_get()" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe 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 <[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.1.y
git checkout FETCH_HEAD
git cherry-pick -x d6b8b02a27b3dd09ec12144322b3dac46d9bc9ef
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026061530-traps-spool-56b7@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d6b8b02a27b3dd09ec12144322b3dac46d9bc9ef Mon Sep 17 00:00:00 2001
From: SeongJae Park <[email protected]>
Date: Mon, 25 May 2026 09:22:55 -0700
Subject: [PATCH] mm/damon/ops-common: call folio_test_lru() after folio_get()
damon_get_folio() speculatively calls folio_test_lru() before folio_try_get(). The folio can get freed and reallocated to a tail page. In the case, VM_BUG_ON_PGFLAGS() in const_folio_flags() can be triggered. Remove the speculative call.
Also mark folio_test_lru() check right after folio_try_get() success as no more unlikely.
The race should be rare. Also the problem can happen only if the kernel has enabled CONFIG_DEBUG_VM_PGFLAGS. No real world report of this issue has been made so far. This fix is based on only theoretical analysis. That said, a bug is a bug. A similar issue was also fixed via commit 3203b3ab0fcf ("mm/filemap: don't call folio_test_locked() without a reference in next_uptodate_folio()"). I don't expect this change will make a meaningful impact to DAMON performance in the real world, though I will be happy to be corrected from the real world reports.
The issue was discovered [1] by Sashiko.
mm/damon/ops-common.c +2 -2
@@ -32,9 +32,9 @@ struct folio *damon_get_folio(unsigned long pfn)return NULL ; folio =page_folio (page); -if (!folio_test_lru (folio) || !folio_try_get (folio)) +if (!folio_try_get (folio))return NULL ; -if (unlikely (page_folio (page) != folio || !folio_test_lru (folio))) { +if (unlikely (page_folio (page) != folio) || !folio_test_lru (folio)) {folio_put (folio); folio =NULL ; }
Sasha Levin
maintainerPATCH 1/1 mm/damon/ops-common: call folio_test_lru() after folio_get()
From: SeongJae Park <[email protected]>
[ Upstream commit d6b8b02a27b3dd09ec12144322b3dac46d9bc9ef ]
damon_get_folio() speculatively calls folio_test_lru() before folio_try_get(). The folio can get freed and reallocated to a tail page. In the case, VM_BUG_ON_PGFLAGS() in const_folio_flags() can be triggered. Remove the speculative call.
Also mark folio_test_lru() check right after folio_try_get() success as no more unlikely.
The race should be rare. Also the problem can happen only if the kernel has enabled CONFIG_DEBUG_VM_PGFLAGS. No real world report of this issue has been made so far. This fix is based on only theoretical analysis. That said, a bug is a bug. A similar issue was also fixed via commit 3203b3ab0fcf ("mm/filemap: don't call folio_test_locked() without a reference in next_uptodate_folio()"). I don't expect this change will make a meaningful impact to DAMON performance in the real world, though I will be happy to be corrected from the real world reports.
The issue was discovered [1] by Sashiko.
--- mm/damon/ops-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/damon/ops-common.c +2 -2
@@ -23,10 +23,10 @@ struct page *damon_get_page(unsigned long pfn) {struct page *page =pfn_to_online_page (pfn); -if (!page || !PageLRU (page) || !get_page_unless_zero (page)) +if (!page || !get_page_unless_zero (page))return NULL ; -if (unlikely (!PageLRU (page))) { +if (!PageLRU (page)) {put_page (page); page =NULL ; }
Signature · 1 line
2.53.0
Re: [PATCH 6.1.y] mm/damon/ops-common: call folio_test_lru() after folio_get()
Quoted 23 lines · On Mon, 15 Jun 2026 15:03:29 -0400 Sasha Levin <[email protected]> wrote:
From: SeongJae Park <[email protected]>
[ Upstream commit
d6b8b02a27b3dd09ec12144322b3dac46d9bc9ef]
damon_get_folio()speculatively callsfolio_test_lru()beforefolio_try_get(). The folio can get freed and reallocated to a tail page. In the case,VM_BUG_ON_PGFLAGS()inconst_folio_flags()can be triggered. Remove the speculative call.Also mark
folio_test_lru()check right afterfolio_try_get()success as no more unlikely.The race should be rare. Also the problem can happen only if the kernel has enabled
CONFIG_DEBUG_VM_PGFLAGS. No real world report of this issue has been made so far. This fix is based on only theoretical analysis. That said, a bug is a bug. A similar issue was also fixed via commit3203b3ab0fcf("mm/filemap: don't callfolio_test_locked()without a reference innext_uptodate_folio()"). I don't expect this change will make a meaningful impact to DAMON performance in the real world, though I will be happy to be corrected from the real world reports.The issue was discovered [1] by Sashiko.
Quoted 10 lines
Fixes 3f49584b262c ("mm/damon: implement primitives for the virtual memory address spaces")Signed-off-by SeongJae Park <[email protected]>Cc Fernand Sieber <[email protected]>Cc Leonard Foerster <[email protected]>Cc Shakeel Butt <[email protected]>Cc <[email protected]> # 5.15.xSigned-off-by Andrew Morton <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Thank you for fixing the conflict, Sasha!
Thanks,
SJ
[...]