Skip to content

RFC mm: separate the fallback to mmap_lock from VM_FAULT_RETRY

Suren Baghdasaryan linux-doc linux-mm linux-riscv linux-s390 linuxppc-dev lkml loongarch 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2mm: introduce should_retry_mm_fault() helperarch/arm/mm/fault.c arch/arm64/mm/fault.c arch/loongarch/mm/fault.c +7 more+28 -160 replies
2/2mm: split VM_FAULT_RETRY_LOCK_MM out of VM_FAULT_RETRYDocumentation/filesystems/porting.rst include/linux/mm_types.h mm/huge_memory.c +3 more+30 -180 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] mm: separate the fallback to mmap_lock from VM_FAULT_RETRY

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

Signature · 1 line
2.56.1.839.g22a8290db9-goog