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/nommu.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/nommu.c')
-rw-r--r-- | mm/nommu.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index 215c62296028..fe9f4fa4a7a7 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -1205,7 +1205,8 @@ unsigned long do_mmap(struct file *file, | |||
1205 | unsigned long flags, | 1205 | unsigned long flags, |
1206 | vm_flags_t vm_flags, | 1206 | vm_flags_t vm_flags, |
1207 | unsigned long pgoff, | 1207 | unsigned long pgoff, |
1208 | unsigned long *populate) | 1208 | unsigned long *populate, |
1209 | struct list_head *uf) | ||
1209 | { | 1210 | { |
1210 | struct vm_area_struct *vma; | 1211 | struct vm_area_struct *vma; |
1211 | struct vm_region *region; | 1212 | struct vm_region *region; |
@@ -1577,7 +1578,7 @@ static int shrink_vma(struct mm_struct *mm, | |||
1577 | * - under NOMMU conditions the chunk to be unmapped must be backed by a single | 1578 | * - under NOMMU conditions the chunk to be unmapped must be backed by a single |
1578 | * VMA, though it need not cover the whole VMA | 1579 | * VMA, though it need not cover the whole VMA |
1579 | */ | 1580 | */ |
1580 | int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) | 1581 | int do_munmap(struct mm_struct *mm, unsigned long start, size_t len, struct list_head *uf) |
1581 | { | 1582 | { |
1582 | struct vm_area_struct *vma; | 1583 | struct vm_area_struct *vma; |
1583 | unsigned long end; | 1584 | unsigned long end; |
@@ -1643,7 +1644,7 @@ int vm_munmap(unsigned long addr, size_t len) | |||
1643 | int ret; | 1644 | int ret; |
1644 | 1645 | ||
1645 | down_write(&mm->mmap_sem); | 1646 | down_write(&mm->mmap_sem); |
1646 | ret = do_munmap(mm, addr, len); | 1647 | ret = do_munmap(mm, addr, len, NULL); |
1647 | up_write(&mm->mmap_sem); | 1648 | up_write(&mm->mmap_sem); |
1648 | return ret; | 1649 | return ret; |
1649 | } | 1650 | } |