LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] Per-vma lock support for swap and userfaults
@ 2023-06-09  0:51 Suren Baghdasaryan
  2023-06-09  0:51 ` [PATCH v2 1/6] swap: remove remnants of polling from read_swap_cache_async Suren Baghdasaryan
                   ` (5 more replies)
  0 siblings, 6 replies; 36+ messages in thread
From: Suren Baghdasaryan @ 2023-06-09  0:51 UTC (permalink / raw)
  To: akpm
  Cc: willy, hannes, mhocko, josef, jack, ldufour, laurent.dufour,
	michel, liam.howlett, jglisse, vbabka, minchan, dave,
	punit.agrawal, lstoakes, hdanton, apopple, peterx, ying.huang,
	david, yuzhao, dhowells, hughd, viro, brauner, pasha.tatashin,
	surenb, linux-mm, linux-fsdevel, linux-kernel, kernel-team

When per-vma locks were introduced in [1] several types of page faults
would still fall back to mmap_lock to keep the patchset simple. Among them
are swap and userfault pages. The main reason for skipping those cases was
the fact that mmap_lock could be dropped while handling these faults and
that required additional logic to be implemented.
Implement the mechanism to allow per-vma locks to be dropped for these
cases. When that happens handle_mm_fault returns new VM_FAULT_VMA_UNLOCKED
vm_fault_reason bit along with VM_FAULT_RETRY to indicate that VMA lock
was dropped. Naturally, once VMA lock is dropped that VMA should be
assumed unstable and can't be used.

Changes since v1 posted at [2]
- New patch 1/6 to remove do_poll parameter from read_swap_cache_async(),
per Huang Ying
- New patch 3/6 to separate VM_FAULT_COMPLETED addition,
per Alistair Popple
- Added comment for VM_FAULT_VMA_UNLOCKED in 4/6, per Alistair Popple
- New patch 6/6 to handle userfaults under VMA lock

Note: I tried implementing Matthew's suggestion in [3] to add vmf_end_read
but that gets quite messy since it would require changing code for every
architecture when we change handle_mm_fault interface.

Note: patch 4/6 will cause a trivial merge conflict in arch/arm64/mm/fault.c
when applied over mm-unstable branch due to a patch from ARM64 tree [4]
which is missing in mm-unstable.

[1] https://lore.kernel.org/all/20230227173632.3292573-1-surenb@google.com/
[2] https://lore.kernel.org/all/20230501175025.36233-1-surenb@google.com/
[3] https://lore.kernel.org/all/ZFEeHqzBJ6iOsRN+@casper.infradead.org/
[4] https://lore.kernel.org/all/20230524131305.2808-1-jszhang@kernel.org/

Suren Baghdasaryan (6):
  swap: remove remnants of polling from read_swap_cache_async
  mm: handle swap page faults under VMA lock if page is uncontended
  mm: add missing VM_FAULT_RESULT_TRACE name for VM_FAULT_COMPLETED
  mm: drop VMA lock before waiting for migration
  mm: implement folio wait under VMA lock
  mm: handle userfaults under VMA lock

 arch/arm64/mm/fault.c    |  3 ++-
 arch/powerpc/mm/fault.c  |  3 ++-
 arch/s390/mm/fault.c     |  3 ++-
 arch/x86/mm/fault.c      |  3 ++-
 fs/userfaultfd.c         | 42 ++++++++++++++++++-----------------
 include/linux/mm_types.h |  7 +++++-
 include/linux/pagemap.h  | 14 ++++++++----
 mm/filemap.c             | 37 +++++++++++++++++++------------
 mm/madvise.c             |  4 ++--
 mm/memory.c              | 48 ++++++++++++++++++++++------------------
 mm/swap.h                |  1 -
 mm/swap_state.c          | 12 +++++-----
 12 files changed, 103 insertions(+), 74 deletions(-)

-- 
2.41.0.162.gfafddb0af9-goog


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

end of thread, other threads:[~2023-06-12 18:58 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09  0:51 [PATCH v2 0/6] Per-vma lock support for swap and userfaults Suren Baghdasaryan
2023-06-09  0:51 ` [PATCH v2 1/6] swap: remove remnants of polling from read_swap_cache_async Suren Baghdasaryan
2023-06-09  1:57   ` Huang, Ying
2023-06-09  3:13     ` Ming Lei
2023-06-09 18:50       ` Suren Baghdasaryan
2023-06-12  4:53   ` Christoph Hellwig
2023-06-09  0:51 ` [PATCH v2 2/6] mm: handle swap page faults under VMA lock if page is uncontended Suren Baghdasaryan
2023-06-09 20:25   ` Peter Xu
2023-06-09 20:35     ` Matthew Wilcox
2023-06-09 20:45       ` Peter Xu
2023-06-09 22:34         ` Suren Baghdasaryan
2023-06-12 13:59           ` Peter Xu
2023-06-12 16:09             ` Suren Baghdasaryan
2023-06-09  0:51 ` [PATCH v2 3/6] mm: add missing VM_FAULT_RESULT_TRACE name for VM_FAULT_COMPLETED Suren Baghdasaryan
2023-06-09 20:34   ` Peter Xu
2023-06-09  0:51 ` [PATCH v2 4/6] mm: drop VMA lock before waiting for migration Suren Baghdasaryan
2023-06-09 20:42   ` Peter Xu
2023-06-09 22:30     ` Suren Baghdasaryan
2023-06-10  1:29       ` Suren Baghdasaryan
2023-06-12 13:36         ` Peter Xu
2023-06-12 16:07           ` Suren Baghdasaryan
2023-06-12 18:34             ` Peter Xu
2023-06-12 18:44               ` Suren Baghdasaryan
2023-06-12 18:57                 ` Peter Xu
2023-06-12 13:28       ` Peter Xu
2023-06-12 15:41         ` Suren Baghdasaryan
2023-06-09  0:51 ` [PATCH v2 5/6] mm: implement folio wait under VMA lock Suren Baghdasaryan
2023-06-09 15:03   ` Matthew Wilcox
2023-06-09 18:49     ` Suren Baghdasaryan
2023-06-09 18:55       ` Suren Baghdasaryan
2023-06-09 19:36         ` Matthew Wilcox
2023-06-09 22:49           ` Suren Baghdasaryan
2023-06-09 20:54   ` Peter Xu
2023-06-09 22:48     ` Suren Baghdasaryan
2023-06-12 13:56       ` Peter Xu
2023-06-09  0:51 ` [PATCH v2 6/6] mm: handle userfaults " Suren Baghdasaryan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).