Skip to contentSkip to conversation

userfaultfd-non-cooperative-wake-userfaults-after-uffdio_unregister.patch removed from -mm tree

merged [email protected] 1 participant 1 message Feb 23, 2017

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: userfaultfd: non-cooperative: wake userfaults after UFFDIO_UNREGISTER
has been removed from the -mm tree. Its filename was
userfaultfd-non-cooperative-wake-userfaults-after-uffdio_unregister.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Andrea Arcangeli <[email protected]>
Subject: userfaultfd: non-cooperative: wake userfaults after UFFDIO_UNREGISTER

Userfaults may still happen after the userfaultfd monitor thread received a UFFD_EVENT_MADVDONTNEED until UFFDIO_UNREGISTER is run.

Wake any pending userfault within UFFDIO_UNREGISTER protected by the mmap_sem for writing, so they will not be reported to userland leading to UFFDIO_COPY returning -EINVAL (as the range was already unregistered) and they will not hang permanently either.

Cc "Dr. David Alan Gilbert" <[email protected]>
Cc Hillf Danton <[email protected]>
Cc Michael Rapoport <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Pavel Emelyanov <[email protected]>

---

 fs/userfaultfd.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
fs/userfaultfd.c renamed from fs/userfaultfd.c~userfaultfd-non-cooperative-wake-userfaults-after-uffdio_unregister +13 -0
diff -puN fs/userfaultfd.c~userfaultfd-non-cooperative-wake-userfaults-after-uffdio_unregister fs/userfaultfd.c
@@ -1302,6 +1302,19 @@ static int userfaultfd_unregister(struct
 			start = vma->vm_start;
 		vma_end = min(end, vma->vm_end);
 
+		if (userfaultfd_missing(vma)) {
+			/*
+			 * Wake any concurrent pending userfault while
+			 * we unregister, so they will not hang
+			 * permanently and it avoids userland to call
+			 * UFFDIO_WAKE explicitly.
+			 */
+			struct userfaultfd_wake_range range;
+			range.start = start;
+			range.len = vma_end - start;
+			wake_userfault(vma->vm_userfaultfd_ctx.ctx, &range);
+		}
+
 		new_flags = vma->vm_flags & ~(VM_UFFD_MISSING | VM_UFFD_WP);
 		prev = vma_merge(mm, prev, start, vma_end, new_flags,
 				 vma->anon_vma, vma->vm_file, vma->vm_pgoff,

_

Patches currently in -mm which might be from [email protected] are

userfaultfd-mcopy_atomic-return-enoent-when-no-compatible-vma-found-fix-2.patch userfaultfd-mcopy_atomic-return-enoent-when-no-compatible-vma-found-fix-2-fix-fix.patch