Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] mm: separate the fallback to mmap_lock from VM_FAULT_RETRY
@ 2026-11-29 20:22 Suren Baghdasaryan
  2026-11-29 20:22 ` [RFC PATCH 1/2] mm: introduce should_retry_mm_fault() helper Suren Baghdasaryan
  2026-11-29 20:22 ` [RFC PATCH 2/2] mm: split VM_FAULT_RETRY_LOCK_MM out of VM_FAULT_RETRY Suren Baghdasaryan
  0 siblings, 2 replies; 3+ messages in thread
From: Suren Baghdasaryan @ 2026-11-29 20:22 UTC (permalink / raw)
  To: akpm
  Cc: david, willy, ljs, liam, vbabka, rppt, jannh, ziy, baolin.wang,
	nico.pache, ryan.roberts, dev.jain, baohua, lance.yang,
	usama.arif, kas, muchun.song, osalvador, dave.hansen, luto,
	peterz, linux, catalin.marinas, will, mark.rutland, chenhuacai,
	kernel, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde, pjw,
	palmer, aou, alex, agordeev, gerald.schaefer, corbet, skhan,
	rdunlap, linux-mm, linux-kernel, linux-arm-kernel, loongarch,
	linuxppc-dev, linux-riscv, linux-s390, linux-doc,
	Suren Baghdasaryan

VM_FAULT_RETRY is returned from the page fault path for two different
reasons.  Usually it means that the fault handler had to drop its lock,
typically to wait for something, and the fault has to be handled again.
With per-VMA locks it is also returned when the fault can not be handled
under the per-VMA lock at all and has to be handled under mmap_lock. The
architecture fault handlers can not tell these two cases apart, so every
VM_FAULT_RETRY from a fault handled under the per-VMA lock results in a
retry under mmap_lock.

This series separates the two cases:

Patch 1 introduces should_retry_mm_fault() and uses it in the per-VMA lock
path of the architecture fault handlers, in fault_signal_pending() and in
mm_account_fault() instead of testing VM_FAULT_RETRY directly.

Patch 2 introduces VM_FAULT_RETRY_LOCK_MM and returns it from the places
that fall back from the per-VMA lock to mmap_lock: vmf_can_call_fault(),
__vmf_anon_prepare() and the device private paths in do_swap_page() and
do_huge_pmd_device_private(). VM_FAULT_RETRY keeps being returned in all
the other cases.

should_retry_mm_fault() accepts both codes and the architecture fault
handlers keep retrying under mmap_lock in both cases, so no functional
change is intended.  The series only makes the reason for the retry
visible to the callers of handle_mm_fault().

Only the checks in the per-VMA lock path are converted.  The checks done
after handling a fault under mmap_lock still test VM_FAULT_RETRY, since
VM_FAULT_RETRY_LOCK_MM is never returned there.

Drivers and filesystems that return VM_FAULT_RETRY are left unchanged.
panthor_gem_any_fault() might return it after dropping the per-VMA lock
and waiting, which is treated as a generic retry.

The series is based on mm-unstable.

Suren Baghdasaryan (2):
  mm: introduce should_retry_mm_fault() helper
  mm: split VM_FAULT_RETRY_LOCK_MM out of VM_FAULT_RETRY

 Documentation/filesystems/porting.rst |  4 ++--
 arch/arm/mm/fault.c                   |  4 ++--
 arch/arm64/mm/fault.c                 |  4 ++--
 arch/loongarch/mm/fault.c             |  4 ++--
 arch/powerpc/mm/fault.c               |  4 ++--
 arch/riscv/mm/fault.c                 |  4 ++--
 arch/s390/mm/fault.c                  |  4 ++--
 arch/x86/mm/fault.c                   |  4 ++--
 include/linux/mm_types.h              | 23 ++++++++++++++++++++++-
 include/linux/sched/signal.h          |  2 +-
 mm/huge_memory.c                      |  2 +-
 mm/hugetlb.c                          |  9 +++++----
 mm/internal.h                         |  2 +-
 mm/memory.c                           | 20 +++++++++++---------
 14 files changed, 57 insertions(+), 33 deletions(-)


base-commit: 890dc639d8a33e674caa7ea9993dbd2416660447
-- 
2.56.1.839.g22a8290db9-goog



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

end of thread, other threads:[~2026-11-29 20:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 20:22 [RFC PATCH 0/2] mm: separate the fallback to mmap_lock from VM_FAULT_RETRY Suren Baghdasaryan
2026-11-29 20:22 ` [RFC PATCH 1/2] mm: introduce should_retry_mm_fault() helper Suren Baghdasaryan
2026-11-29 20:22 ` [RFC PATCH 2/2] mm: split VM_FAULT_RETRY_LOCK_MM out of VM_FAULT_RETRY Suren Baghdasaryan

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