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>
Showing the changes to include/uapi/linux (1 of 15 files). Show all
Unified · Split
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \ |
| 22 | 22 | UFFD_FEATURE_EVENT_REMAP | \ |
| 23 | 23 | UFFD_FEATURE_EVENT_REMOVE | \ |
| 24 | + UFFD_FEATURE_EVENT_UNMAP | \ | |
| 24 | 25 | UFFD_FEATURE_MISSING_HUGETLBFS | \ |
| 25 | 26 | UFFD_FEATURE_MISSING_SHMEM) |
| 26 | 27 | #define UFFD_API_IOCTLS \ |
| @@ -110,6 +111,7 @@ struct uffd_msg { · 83 unmodified lines | ||
| 110 | 111 | #define UFFD_EVENT_FORK 0x13 |
| 111 | 112 | #define UFFD_EVENT_REMAP 0x14 |
| 112 | 113 | #define UFFD_EVENT_REMOVE 0x15 |
| 114 | +#define UFFD_EVENT_UNMAP 0x16 | |
| 113 | 115 | |
| 114 | 116 | /* flags for UFFD_EVENT_PAGEFAULT */ |
| 115 | 117 | #define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */ |
| @@ -158,6 +160,7 @@ struct uffdio_api { · 42 unmodified lines | ||
| 158 | 160 | #define UFFD_FEATURE_EVENT_REMOVE (1<<3) |
| 159 | 161 | #define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) |
| 160 | 162 | #define UFFD_FEATURE_MISSING_SHMEM (1<<5) |
| 163 | +#define UFFD_FEATURE_EVENT_UNMAP (1<<6) | |
| 161 | 164 | __u64 features; |
| 162 | 165 | |
| 163 | 166 | __u64 ioctls; |