linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] mm/uffd: Add feature bit UFFD_FEATURE_WP_UNPOPULATED
@ 2023-03-06 21:39 Peter Xu
  2023-03-06 21:39 ` [PATCH v3 1/2] mm/uffd: UFFD_FEATURE_WP_UNPOPULATED Peter Xu
  2023-03-06 21:39 ` [PATCH v3 2/2] selftests/mm: Smoke test WP_UNPOPULATED Peter Xu
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Xu @ 2023-03-06 21:39 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: Muhammad Usama Anjum, peterx, Andrea Arcangeli, Axel Rasmussen,
	Mike Rapoport, Nadav Amit, Paul Gofman, Andrew Morton,
	David Hildenbrand

This is v3 of the patch(set).  Old versions:

v1: https://lore.kernel.org/r/20230215210257.224243-1-peterx@redhat.com
v2: https://lore.kernel.org/r/20230227230044.1596744-1-peterx@redhat.com

Comparing to v2, this fixes a bug that Muhammad reported on reading none
pte failure after wr-protected with WP_UNPOPULATED.  I also split the test
into a separate one.

The new feature bit will make anonymous memory acts the same like file
memory on userfaultfd-wp in that it'll also wr-protect none ptes.

It can be useful in two cases:

(1) Uffd-wp app that needs to wr-protect none ptes like QEMU snapshot, so
    pre-fault can be replaced by enabling this flag and speed up protections

(2) It helps to implement async uffd-wp mode that Muhammad is working on [1]

It's debateable whether this is the most ideal solution because with the
new feature bit set, wr-protect none pte needs to pre-populate the pgtables
to the last level (PAGE_SIZE).  But it seems fine so far to service either
purpose above, so we can leave optimizations for later.

The series brings pte markers to anonymous memory too.  There's some change
in the common mm code path in the 1st patch, great to have some eye looking
at it, but hopefully they're still relatively straightforward.

Thanks,

[1] https://lore.kernel.org/all/Y+v2HJ8+3i%2FKzDBu@x1n/

Peter Xu (2):
  mm/uffd: UFFD_FEATURE_WP_UNPOPULATED
  selftests/mm: Smoke test WP_UNPOPULATED

 fs/userfaultfd.c                         | 14 ++++++
 include/linux/mm_inline.h                |  6 +++
 include/linux/userfaultfd_k.h            |  6 +++
 include/uapi/linux/userfaultfd.h         | 10 +++-
 mm/memory.c                              | 56 ++++++++++++++++------
 mm/mprotect.c                            | 59 ++++++++++++++++++++----
 tools/testing/selftests/mm/userfaultfd.c | 45 +++++++++++++++++-
 7 files changed, 169 insertions(+), 27 deletions(-)

-- 
2.39.1



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

end of thread, other threads:[~2023-03-08 17:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06 21:39 [PATCH v3 0/2] mm/uffd: Add feature bit UFFD_FEATURE_WP_UNPOPULATED Peter Xu
2023-03-06 21:39 ` [PATCH v3 1/2] mm/uffd: UFFD_FEATURE_WP_UNPOPULATED Peter Xu
2023-03-07 16:11   ` David Hildenbrand
2023-03-08 15:31     ` Peter Xu
2023-03-08 15:57       ` David Hildenbrand
2023-03-08 16:51         ` Peter Xu
2023-03-08 17:04           ` David Hildenbrand
2023-03-06 21:39 ` [PATCH v3 2/2] selftests/mm: Smoke test WP_UNPOPULATED Peter Xu

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