diff options
author | Mike Rapoport <rppt@linux.vnet.ibm.com> | 2017-02-24 17:58:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-24 20:46:55 -0500 |
commit | 897ab3e0c49e24b62e2d54d165c7afec6bbca65b (patch) | |
tree | 5fa7e09864d6c959cef33849f6cb10ed04e459e4 /mm/util.c | |
parent | 846b1a0f1db065a8479159dd8fecddb1ebf30547 (diff) |
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>
Diffstat (limited to 'mm/util.c')
-rw-r--r-- | mm/util.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/mman.h> | 11 | #include <linux/mman.h> |
12 | #include <linux/hugetlb.h> | 12 | #include <linux/hugetlb.h> |
13 | #include <linux/vmalloc.h> | 13 | #include <linux/vmalloc.h> |
14 | #include <linux/userfaultfd_k.h> | ||
14 | 15 | ||
15 | #include <asm/sections.h> | 16 | #include <asm/sections.h> |
16 | #include <linux/uaccess.h> | 17 | #include <linux/uaccess.h> |
@@ -297,14 +298,16 @@ unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, | |||
297 | unsigned long ret; | 298 | unsigned long ret; |
298 | struct mm_struct *mm = current->mm; | 299 | struct mm_struct *mm = current->mm; |
299 | unsigned long populate; | 300 | unsigned long populate; |
301 | LIST_HEAD(uf); | ||
300 | 302 | ||
301 | ret = security_mmap_file(file, prot, flag); | 303 | ret = security_mmap_file(file, prot, flag); |
302 | if (!ret) { | 304 | if (!ret) { |
303 | if (down_write_killable(&mm->mmap_sem)) | 305 | if (down_write_killable(&mm->mmap_sem)) |
304 | return -EINTR; | 306 | return -EINTR; |
305 | ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff, | 307 | ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff, |
306 | &populate); | 308 | &populate, &uf); |
307 | up_write(&mm->mmap_sem); | 309 | up_write(&mm->mmap_sem); |
310 | userfaultfd_unmap_complete(mm, &uf); | ||
308 | if (populate) | 311 | if (populate) |
309 | mm_populate(ret, populate); | 312 | mm_populate(ret, populate); |
310 | } | 313 | } |