Skip to contentSkip to conversation

userfaultfd-shmem-support-minor-fault-registration-for-shmem.patch removed from -mm tree

merged [email protected] 1 participant 1 message Jul 6, 2021

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: userfaultfd/shmem: support minor fault registration for shmem
has been removed from the -mm tree. Its filename was
userfaultfd-shmem-support-minor-fault-registration-for-shmem.patch

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

------------------------------------------------------
From: Axel Rasmussen <[email protected]>
Subject: userfaultfd/shmem: support minor fault registration for shmem

This patch allows shmem-backed VMAs to be registered for minor faults. Minor faults are appropriately relayed to userspace in the fault path, for VMAs with the relevant flag.

This commit doesn't hook up the UFFDIO_CONTINUE ioctl for shmem-backed minor faults, though, so userspace doesn't yet have a way to resolve such faults.

Because of this, we also don't yet advertise this as a supported feature. That will be done in a separate commit when the feature is fully implemented.

Cc Alexander Viro <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Brian Geffon <[email protected]>
Cc "Dr . David Alan Gilbert" <[email protected]>
Cc Jerome Glisse <[email protected]>
Cc Joe Perches <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Lokesh Gidra <[email protected]>
Cc Mike Kravetz <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Mina Almasry <[email protected]>
Cc Oliver Upton <[email protected]>
Cc Shaohua Li <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Wang Qing <[email protected]>

---

 fs/userfaultfd.c |    3 +--
 mm/memory.c      |    8 +++++---
 mm/shmem.c       |   12 +++++++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)
fs/userfaultfd.c renamed from fs/userfaultfd.c~userfaultfd-shmem-support-minor-fault-registration-for-shmem +1 -2
@@ -1267,8 +1267,7 @@ static inline bool vma_can_userfault(str
 	}
 
 	if (vm_flags & VM_UFFD_MINOR) {
-		/* FIXME: Add minor fault interception for shmem. */
-		if (!is_vm_hugetlb_page(vma))
+		if (!(is_vm_hugetlb_page(vma) || vma_is_shmem(vma)))
 			return false;
 	}
 
mm/memory.c renamed from mm/memory.c~userfaultfd-shmem-support-minor-fault-registration-for-shmem +5 -3
@@ -4026,9 +4026,11 @@ static vm_fault_t do_read_fault(struct v
 	 * something).
 	 */
 	if (vma->vm_ops->map_pages && fault_around_bytes >> PAGE_SHIFT > 1) {
-		ret = do_fault_around(vmf);
-		if (ret)
-			return ret;
+		if (likely(!userfaultfd_minor(vmf->vma))) {
+			ret = do_fault_around(vmf);
+			if (ret)
+				return ret;
+		}
 	}
 
 	ret = __do_fault(vmf);
mm/shmem.c renamed from mm/shmem.c~userfaultfd-shmem-support-minor-fault-registration-for-shmem +11 -1
@@ -1797,7 +1797,7 @@ unlock:
  * vm. If we swap it in we mark it dirty since we also free the swap
  * entry since a page cannot live in both the swap and page cache.
  *
- * vmf and fault_type are only supplied by shmem_fault:
+ * vma, vmf, and fault_type are only supplied by shmem_fault:
  * otherwise they are NULL.
  */
 static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
@@ -1832,6 +1832,16 @@ repeat:
 
 	page = pagecache_get_page(mapping, index,
 					FGP_ENTRY | FGP_HEAD | FGP_LOCK, 0);
+
+	if (page && vma && userfaultfd_minor(vma)) {
+		if (!xa_is_value(page)) {
+			unlock_page(page);
+			put_page(page);
+		}
+		*fault_type = handle_userfault(vmf, VM_UFFD_MINOR);
+		return 0;
+	}
+
 	if (xa_is_value(page)) {
 		error = shmem_swapin_page(inode, index, &page,
 					  sgp, gfp, vma, fault_type);

_

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