* [merged] userfaultfd-call-userfaultfd_unmap_prep-only-if-__split_vma-succeeds.patch removed from -mm tree
@ 2017-09-07 18:41 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2017-09-07 18:41 UTC (permalink / raw)
To: a.perevalov, aarcange, dgilbert, maxime.coquelin, mike.kravetz,
mm-commits, rppt
The patch titled
Subject: userfaultfd: call userfaultfd_unmap_prep only if __split_vma succeeds
has been removed from the -mm tree. Its filename was
userfaultfd-call-userfaultfd_unmap_prep-only-if-__split_vma-succeeds.patch
This patch was dropped because it was merged into mainline or a subsystem tree
------------------------------------------------------
From: Andrea Arcangeli <aarcange@redhat.com>
Subject: userfaultfd: call userfaultfd_unmap_prep only if __split_vma succeeds
A __split_vma is not a worthy event to report, and it's definitely not a
unmap so it would be incorrect to report unmap for the whole region to the
userfaultfd manager if a __split_vma fails.
So only call userfaultfd_unmap_prep after the __vma_splitting is over and
do_munmap cannot fail anymore.
Also add unlikely because it's better to optimize for the vast majority of
apps that aren't using userfaultfd in a non cooperative way. Ideally we
should also find a way to eliminate the branch entirely if
CONFIG_USERFAULTFD=n, but it would complicate things so stick to unlikely
for now.
Link: http://lkml.kernel.org/r/20170802165145.22628-5-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Alexey Perevalov <a.perevalov@samsung.com>
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/mmap.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff -puN mm/mmap.c~userfaultfd-call-userfaultfd_unmap_prep-only-if-__split_vma-succeeds mm/mmap.c
--- a/mm/mmap.c~userfaultfd-call-userfaultfd_unmap_prep-only-if-__split_vma-succeeds
+++ a/mm/mmap.c
@@ -2639,13 +2639,6 @@ int do_munmap(struct mm_struct *mm, unsi
if (vma->vm_start >= end)
return 0;
- if (uf) {
- int error = userfaultfd_unmap_prep(vma, start, end, uf);
-
- if (error)
- return error;
- }
-
/*
* If we need to split any vma, do it now to save pain later.
*
@@ -2679,6 +2672,21 @@ int do_munmap(struct mm_struct *mm, unsi
}
vma = prev ? prev->vm_next : mm->mmap;
+ if (unlikely(uf)) {
+ /*
+ * If userfaultfd_unmap_prep returns an error the vmas
+ * will remain splitted, but userland will get a
+ * highly unexpected error anyway. This is no
+ * different than the case where the first of the two
+ * __split_vma fails, but we don't undo the first
+ * split, despite we could. This is unlikely enough
+ * failure that it's not worth optimizing it for.
+ */
+ int error = userfaultfd_unmap_prep(vma, start, end, uf);
+ if (error)
+ return error;
+ }
+
/*
* unlock any mlock()ed ranges before detaching vmas
*/
_
Patches currently in -mm which might be from aarcange@redhat.com are
userfaultfd-non-cooperative-closing-the-uffd-without-triggering-sigbus.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-07 18:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-07 18:41 [merged] userfaultfd-call-userfaultfd_unmap_prep-only-if-__split_vma-succeeds.patch removed from -mm tree akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).