Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

userfaultfd/shmem: advertise shmem minor fault support

Now that the feature is fully implemented (the faulting path hooks exist
so userspace is notified, and the ioctl to resolve such faults is
available), advertise this as a supported feature.

Link: https://lkml.kernel.org/r/20210503180737.2487560-6-axelrasmussen@google.com
Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Peter Xu <peterx@redhat.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Brian Geffon <bgeffon@google.com>
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Joe Perches <joe@perches.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Mina Almasry <almasrymina@google.com>
Cc: Oliver Upton <oupton@google.com>
Cc: Shaohua Li <shli@fb.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Wang Qing <wangqing@vivo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Axel Rasmussen and committed by
Linus Torvalds
964ab004 15313257

+10 -3
+2 -1
Documentation/admin-guide/mm/userfaultfd.rst
··· 77 77 78 78 - ``UFFD_FEATURE_MINOR_HUGETLBFS`` indicates that the kernel supports 79 79 ``UFFDIO_REGISTER_MODE_MINOR`` registration for hugetlbfs virtual memory 80 - areas. 80 + areas. ``UFFD_FEATURE_MINOR_SHMEM`` is the analogous feature indicating 81 + support for shmem virtual memory areas. 81 82 82 83 The userland application should set the feature flags it intends to use 83 84 when invoking the ``UFFDIO_API`` ioctl, to request that those features be
+2 -1
fs/userfaultfd.c
··· 1944 1944 /* report all available features and ioctls to userland */ 1945 1945 uffdio_api.features = UFFD_API_FEATURES; 1946 1946 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR 1947 - uffdio_api.features &= ~UFFD_FEATURE_MINOR_HUGETLBFS; 1947 + uffdio_api.features &= 1948 + ~(UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM); 1948 1949 #endif 1949 1950 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP 1950 1951 uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP;
+6 -1
include/uapi/linux/userfaultfd.h
··· 31 31 UFFD_FEATURE_MISSING_SHMEM | \ 32 32 UFFD_FEATURE_SIGBUS | \ 33 33 UFFD_FEATURE_THREAD_ID | \ 34 - UFFD_FEATURE_MINOR_HUGETLBFS) 34 + UFFD_FEATURE_MINOR_HUGETLBFS | \ 35 + UFFD_FEATURE_MINOR_SHMEM) 35 36 #define UFFD_API_IOCTLS \ 36 37 ((__u64)1 << _UFFDIO_REGISTER | \ 37 38 (__u64)1 << _UFFDIO_UNREGISTER | \ ··· 186 185 * UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults 187 186 * can be intercepted (via REGISTER_MODE_MINOR) for 188 187 * hugetlbfs-backed pages. 188 + * 189 + * UFFD_FEATURE_MINOR_SHMEM indicates the same support as 190 + * UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead. 189 191 */ 190 192 #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) 191 193 #define UFFD_FEATURE_EVENT_FORK (1<<1) ··· 200 196 #define UFFD_FEATURE_SIGBUS (1<<7) 201 197 #define UFFD_FEATURE_THREAD_ID (1<<8) 202 198 #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9) 199 + #define UFFD_FEATURE_MINOR_SHMEM (1<<10) 203 200 __u64 features; 204 201 205 202 __u64 ioctls;