History

userfaultfd: non-cooperative: add event for memory unmaps

When a non-cooperative userfaultfd monitor copies pages in the background, it may encounter regions that were already unmapped. Addition of UFFD_EVENT_UNMAP allows the uffd monitor to track precisely changes in the virtual memory layout. Since there might be different uffd contexts for the affected VMAs, we first should create a temporary representation for the unmap event for each uffd context and then notify them one by one to the appropriate userfault file descriptors. The event notification occurs after the mmap_sem has been released. [arnd@arndb.de: fix nommu build] Link: http://lkml.kernel.org/r/20170203165141.3665284-1-arnd@arndb.de [mhocko@suse.com: fix nommu build] Link: http://lkml.kernel.org/r/20170202091503.GA22823@dhcp22.suse.cz Link: http://lkml.kernel.org/r/1485542673-24387-3-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Mike Rapoport committed 9 years ago

Commit 897ab3e1 parent 846b1a015 files · +160 −45Browse files

Showing the changes to include/uapi/linux (1 of 15 files). Show all

Unified · Split

include/uapi/linux/userfaultfd.h+3−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \
2222 UFFD_FEATURE_EVENT_REMAP | \
2323 UFFD_FEATURE_EVENT_REMOVE | \
24+ UFFD_FEATURE_EVENT_UNMAP | \
2425 UFFD_FEATURE_MISSING_HUGETLBFS | \
2526 UFFD_FEATURE_MISSING_SHMEM)
2627 #define UFFD_API_IOCTLS \
@@ -110,6 +111,7 @@ struct uffd_msg { · 83 unmodified lines
110111 #define UFFD_EVENT_FORK 0x13
111112 #define UFFD_EVENT_REMAP 0x14
112113 #define UFFD_EVENT_REMOVE 0x15
114+#define UFFD_EVENT_UNMAP 0x16
113115
114116 /* flags for UFFD_EVENT_PAGEFAULT */
115117 #define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */
@@ -158,6 +160,7 @@ struct uffdio_api { · 42 unmodified lines
158160 #define UFFD_FEATURE_EVENT_REMOVE (1<<3)
159161 #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4)
160162 #define UFFD_FEATURE_MISSING_SHMEM (1<<5)
163+#define UFFD_FEATURE_EVENT_UNMAP (1<<6)
161164 __u64 features;
162165
163166 __u64 ioctls;