]> git.baikalelectronics.ru Git - kernel.git/commitdiff
userfaultfd/shmem: advertise shmem minor fault support
authorAxel Rasmussen <axelrasmussen@google.com>
Thu, 1 Jul 2021 01:49:27 +0000 (18:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 03:47:27 +0000 (20:47 -0700)
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>
Documentation/admin-guide/mm/userfaultfd.rst
fs/userfaultfd.c
include/uapi/linux/userfaultfd.h

index 3aa38e8b8361d821e26400a0d1c80c6a1174f61d..6528036093e1fb5a56cf3a7a8fdf0c43fa7e6fe2 100644 (file)
@@ -77,7 +77,8 @@ events, except page fault notifications, may be generated:
 
 - ``UFFD_FEATURE_MINOR_HUGETLBFS`` indicates that the kernel supports
   ``UFFDIO_REGISTER_MODE_MINOR`` registration for hugetlbfs virtual memory
-  areas.
+  areas. ``UFFD_FEATURE_MINOR_SHMEM`` is the analogous feature indicating
+  support for shmem virtual memory areas.
 
 The userland application should set the feature flags it intends to use
 when invoking the ``UFFDIO_API`` ioctl, to request that those features be
index 82ef253d66b68356e3dd2ec27bac21ef56fc1420..19ebae443ade96cf454bb4b5e79f36beeb47b295 100644 (file)
@@ -1944,7 +1944,8 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
        /* report all available features and ioctls to userland */
        uffdio_api.features = UFFD_API_FEATURES;
 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
-       uffdio_api.features &= ~UFFD_FEATURE_MINOR_HUGETLBFS;
+       uffdio_api.features &=
+               ~(UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM);
 #endif
 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
        uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP;
index 650480f41f1d5f9f2776c2d5e000ecc89453cba7..05b31d60acf654bb5c38d149c6823b8712c5c893 100644 (file)
@@ -31,7 +31,8 @@
                           UFFD_FEATURE_MISSING_SHMEM |         \
                           UFFD_FEATURE_SIGBUS |                \
                           UFFD_FEATURE_THREAD_ID |             \
-                          UFFD_FEATURE_MINOR_HUGETLBFS)
+                          UFFD_FEATURE_MINOR_HUGETLBFS |       \
+                          UFFD_FEATURE_MINOR_SHMEM)
 #define UFFD_API_IOCTLS                                \
        ((__u64)1 << _UFFDIO_REGISTER |         \
         (__u64)1 << _UFFDIO_UNREGISTER |       \
@@ -185,6 +186,9 @@ struct uffdio_api {
         * UFFD_FEATURE_MINOR_HUGETLBFS indicates that minor faults
         * can be intercepted (via REGISTER_MODE_MINOR) for
         * hugetlbfs-backed pages.
+        *
+        * UFFD_FEATURE_MINOR_SHMEM indicates the same support as
+        * UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead.
         */
 #define UFFD_FEATURE_PAGEFAULT_FLAG_WP         (1<<0)
 #define UFFD_FEATURE_EVENT_FORK                        (1<<1)
@@ -196,6 +200,7 @@ struct uffdio_api {
 #define UFFD_FEATURE_SIGBUS                    (1<<7)
 #define UFFD_FEATURE_THREAD_ID                 (1<<8)
 #define UFFD_FEATURE_MINOR_HUGETLBFS           (1<<9)
+#define UFFD_FEATURE_MINOR_SHMEM               (1<<10)
        __u64 features;
 
        __u64 ioctls;