Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mm: don't allocate page tables with the folio locked
@ 2026-11-25  9:59 Jose A. Perez de Azpillaga
  2026-11-25  9:59 ` [PATCH 1/4] mm/khugepaged: allocate page tables before locking the folio Jose A. Perez de Azpillaga
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-11-25  9:59 UTC (permalink / raw)
  To: David Hildenbrand, Matthew Wilcox (Oracle), Jan Kara,
	Andrew Morton, Zi Yan, Zach O'Keefe, Lorenzo Stoakes,
	Dev Jain, Baolin Wang, Hugh Dickins, Kiryl Shutsemau,
	Johannes Weiner, Rik van Riel, Song Liu
  Cc: Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Michal Hocko,
	Nico Pache, Ryan Roberts, Barry Song, Lance Yang, Usama Arif,
	linux-mm, linux-fsdevel, Jose A. Perez de Azpillaga

David asked for the remaining places that allocate with __GFP_FS while
holding a folio lock [1]. The fault path and khugepaged still allocate
page tables that way, and collapse_file() calls filemap_release_folio()
and swaps in shmem folios with folio locks held.

Patch 1 allocates the page tables khugepaged needs before locking the
folio.
Patch 2 makes finish_fault() retry the fault instead of allocating when
the page table went away after __do_fault() checked the PMD.
Patch 3 drops the allocation from do_set_pmd(), no caller needs it anymore.
Patch 4 runs the part of collapse_file() that holds folio locks in a NOFS
scope, like __folio_split().

I don't have a real deadlock for patch 4, it just does what [2] does for
splitting, so I left it without a stable tag.

Based on mm/core.git for-next, patch 3 needs the do_set_pmd() changes
there.

Tested on x86_64 and on ppc64le with the hash MMU in QEMU.

[1] https://lore.kernel.org/66e5f9e3-17d4-4635-8919-c67ed562f9f0@kernel.org
[2] https://lore.kernel.org/20261124-migrate_reclaim_deadlock-v2-1-03cc147e1e36@kernel.org

Jose A. Perez de Azpillaga (4):
  mm/khugepaged: allocate page tables before locking the folio
  mm/memory: don't allocate in finish_fault() with the folio locked
  mm/memory: never allocate a page table in do_set_pmd()
  mm/khugepaged: use NOFS while collapse_file() holds folio locks

 include/linux/mm.h |  3 +-
 mm/filemap.c       |  2 +-
 mm/khugepaged.c    | 91 ++++++++++++++++++++++++++++++++++------------
 mm/memory.c        | 39 ++++++++------------
 4 files changed, 85 insertions(+), 50 deletions(-)


base-commit: 98f6b507621822477db7ec7cef8519de0dd243c4
-- 
2.56.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-25 10:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  9:59 [PATCH 0/4] mm: don't allocate page tables with the folio locked Jose A. Perez de Azpillaga
2026-11-25  9:59 ` [PATCH 1/4] mm/khugepaged: allocate page tables before locking the folio Jose A. Perez de Azpillaga
2026-11-25  9:59 ` [PATCH 2/4] mm/memory: don't allocate in finish_fault() with the folio locked Jose A. Perez de Azpillaga
2026-11-25  9:59 ` [PATCH 3/4] mm/memory: never allocate a page table in do_set_pmd() Jose A. Perez de Azpillaga
2026-11-25  9:59 ` [PATCH 4/4] mm/khugepaged: use NOFS while collapse_file() holds folio locks Jose A. Perez de Azpillaga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox