Linux Documentation
 help / color / mirror / Atom feed
* [PATCH 0/3] mm/hmm: Add mmap lock-drop support for userfaultfd-backed mappings
@ 2026-05-01  1:20 Stanislav Kinsburskii
  2026-05-01  1:20 ` [PATCH 1/3] mm/hmm: Add hmm_range_fault_unlockable() for mmap lock-drop support Stanislav Kinsburskii
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stanislav Kinsburskii @ 2026-05-01  1:20 UTC (permalink / raw)
  To: kys, Liam.Howlett, akpm, akpm, david, decui, haiyangz, jgg,
	corbet, leon, longli, ljs, mhocko, rppt, shuah, skhan, surenb,
	vbabka, wei.liu
  Cc: linux-doc, linux-hyperv, linux-kernel, linux-kernel,
	linux-kselftest, linux-mm

This series extends the HMM framework to support userfaultfd-backed memory
by allowing the mmap read lock to be dropped during hmm_range_fault().

Some page fault handlers — most notably userfaultfd — require the mmap lock
to be released so that userspace can resolve the fault. The current HMM
interface never sets FAULT_FLAG_ALLOW_RETRY, making it impossible to fault
in pages from userfaultfd-registered regions.

This series follows the established int *locked pattern from
get_user_pages_remote() in mm/gup.c. A new entry point,
hmm_range_fault_unlockable(), accepts an int *locked parameter. When the
mmap lock is dropped during fault resolution (VM_FAULT_RETRY or
VM_FAULT_COMPLETED), the function returns 0 with *locked = 0, signalling
the caller to restart its walk. The existing hmm_range_fault() is
refactored into a thin wrapper that passes NULL, preserving current
behavior for all existing callers.

Faulting hugetlb pages on the unlockable path is not supported because
walk_hugetlb_range() unconditionally holds and releases
hugetlb_vma_lock_read across the callback; if the mmap lock is dropped
inside the callback, the VMA may be freed before the walk framework's
unlock. Hugetlb pages already present in page tables are handled normally.
Possible approaches to lift this limitation are documented in
Documentation/mm/hmm.rst.

Patch 1 adds hmm_range_fault_unlockable() to the HMM core, refactors
hmm_range_fault() into a wrapper, and updates Documentation/mm/hmm.rst.
Patch 2 converts the mshv driver to use the new API, enabling
userfaultfd-backed guest memory regions. Patch 3 adds a selftest exercising
the unlockable path with a userfaultfd handler that fills pages via
UFFDIO_COPY.

---

Stanislav Kinsburskii (3):
      mm/hmm: Add hmm_range_fault_unlockable() for mmap lock-drop support
      mshv: Use hmm_range_fault_unlockable() for userfaultfd support
      selftests/mm: Add userfaultfd test for HMM unlockable path


 Documentation/mm/hmm.rst               |   89 +++++++++++++++++++++
 drivers/hv/mshv_regions.c              |  127 +++++++++++++++++++++----------
 include/linux/hmm.h                    |    1 
 lib/test_hmm.c                         |  122 +++++++++++++++++++++++++++++
 lib/test_hmm_uapi.h                    |    1 
 mm/hmm.c                               |   91 ++++++++++++++++++++--
 tools/testing/selftests/mm/hmm-tests.c |  133 ++++++++++++++++++++++++++++++++
 7 files changed, 515 insertions(+), 49 deletions(-)


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

end of thread, other threads:[~2026-05-12 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-01  1:20 [PATCH 0/3] mm/hmm: Add mmap lock-drop support for userfaultfd-backed mappings Stanislav Kinsburskii
2026-05-01  1:20 ` [PATCH 1/3] mm/hmm: Add hmm_range_fault_unlockable() for mmap lock-drop support Stanislav Kinsburskii
2026-05-12  8:42   ` David Hildenbrand (Arm)
2026-05-12 16:18     ` Stanislav Kinsburskii
2026-05-12 19:18       ` David Hildenbrand (Arm)
2026-05-01  1:20 ` [PATCH 2/3] mshv: Use hmm_range_fault_unlockable() for userfaultfd support Stanislav Kinsburskii
2026-05-01  1:20 ` [PATCH 3/3] selftests/mm: Add userfaultfd test for HMM unlockable path Stanislav Kinsburskii

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