[merged mm-stable] mm-drop-stale-folio_ref_count==1-check-in-do_swap_page-reuse-logic.patch removed from -mm tree
Andrew Morton <[email protected]> Tue, 04 Aug 2026 19:23:20 -0700
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The quilt patch titled
Subject: mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic
has been removed from the -mm tree. Its filename was
mm-drop-stale-folio_ref_count==1-check-in-do_swap_page-reuse-logic.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "Barry Song (Xiaomi)" <[email protected]>
Subject: mm: drop stale folio_ref_count()==1 check in do_swap_page reuse logic
Date: Thu, 2 Jul 2026 07:59:53 +0800
The "we just allocated them without exposing them to the swapcache" case
no longer exists, as Kairui has routed synchronous I/O through the
swapcache as well in his series "unify swapin use swap cache and cleanup
flags"[1]. As a result, folio_ref_count() should never be 1 in this path,
since at least two references are held (base ref plus swapcache). Remove
the folio_ref_count()==1 check and update the comment accordingly.
The ksm_might_need_to_copy() check may allocate a fresh folio with
folio_ref_count() == 1. Along that path, exclusive has already been
set to true, so the folio can still be reused correctly.
[[email protected]: update comment, per David]
Link: https://lore.kernel.org/[email protected]
Link: https://lore.kernel.org/[email protected]
Link: https://lore.kernel.org/all/[email protected]/ [1]
Signed-off-by: Barry Song (Xiaomi) <[email protected]>
Acked-by: Usama Arif <[email protected]>
Reviewed-by: Kairui Song <[email protected]>
Reviewed-by: Baoquan He <[email protected]>
Acked-by: Shakeel Butt <[email protected]>
Acked-by: David Hildenbrand (Arm) <[email protected]>
Cc: Chris Li <[email protected]>
Cc: Kemeng Shi <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Nhat Pham <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
mm/memory.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
--- a/mm/memory.c~mm-drop-stale-folio_ref_count==1-check-in-do_swap_page-reuse-logic
+++ a/mm/memory.c
@@ -5039,13 +5039,10 @@ check_folio:
pte = pte_mkuffd_wp(pte);
/*
- * Same logic as in do_wp_page(); however, optimize for pages that are
- * certainly not shared either because we just allocated them without
- * exposing them to the swapcache or because the swap entry indicates
- * exclusivity.
+ * Similar logic as in do_wp_page(); however, optimize for pages that
+ * are certainly exclusive.
*/
- if (!folio_test_ksm(folio) &&
- (exclusive || folio_ref_count(folio) == 1)) {
+ if (exclusive) {
if ((vma->vm_flags & VM_WRITE) && !userfaultfd_pte_wp(vma, pte) &&
!pte_needs_soft_dirty_wp(vma, pte)) {
pte = pte_mkwrite(pte, vma);
_
Patches currently in -mm which might be from [email protected] are
arm64-hugetlb-extend-batching-of-multiple-cont_pte-in-a-single-pte-setup.patch
arm64-vmalloc-allow-arch_vmap_pte_range_map_size-to-batch-multiple-cont_pte.patch
mm-vmalloc-extend-page-table-walk-to-support-larger-page_shift-sizes-and-eliminate-page-table-rewalk.patch
mm-vmalloc-map-contiguous-pages-in-batches-for-vmap-if-possible.patch
mm-vmalloc-align-vm_area-so-vmap-can-batch-mappings.patch