From: Mike Rapoport Date: Fri, 24 Feb 2017 22:56:05 +0000 (-0800) Subject: userfaultfd: non-cooperative: add madvise() event for MADV_REMOVE request X-Git-Tag: v5.15~11801^2~113 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6bf53eba98e0c36f51322cd6aa771c0ffa283f3;p=platform%2Fkernel%2Flinux-starfive.git userfaultfd: non-cooperative: add madvise() event for MADV_REMOVE request When a page is removed from a shared mapping, the uffd reader should be notified, so that it won't attempt to handle #PF events for the removed pages. We can reuse the UFFD_EVENT_REMOVE because from the uffd monitor point of view, the semantices of madvise(MADV_DONTNEED) and madvise(MADV_REMOVE) is exactly the same. Link: http://lkml.kernel.org/r/1484814154-1557-3-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport Reviewed-by: Andrea Arcangeli Acked-by: Hillf Danton Acked-by: Pavel Emelyanov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/madvise.c b/mm/madvise.c index ab5ef14..0012071a6 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -520,6 +520,7 @@ static long madvise_remove(struct vm_area_struct *vma, * mmap_sem. */ get_file(f); + userfaultfd_remove(vma, prev, start, end); up_read(¤t->mm->mmap_sem); error = vfs_fallocate(f, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,