]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/gup: Add mm_populate_vma() for use when the vma is known
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 2 Dec 2020 18:15:58 +0000 (13:15 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 28 Jan 2021 01:49:02 +0000 (20:49 -0500)
When a vma is known, avoid calling mm_populate to search for the vma to
populate.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
include/linux/mm.h
mm/gup.c

index ad82ab61bebab7fd7e510b60858a82ed56241ddb..2e3151fdb8cc60e5c113ed4f160e7a7a1d1e6cf7 100644 (file)
@@ -2588,8 +2588,12 @@ static inline void mm_populate(unsigned long addr, unsigned long len)
        /* Ignore errors */
        (void) __mm_populate(addr, len, 1);
 }
+extern void mm_populate_vma(struct vm_area_struct *vma, unsigned long start,
+                           unsigned long end);
 #else
 static inline void mm_populate(unsigned long addr, unsigned long len) {}
+void mm_populate_vma(struct vm_area_struct *vma, unsigned long start,
+                    unsigned long end) {}
 #endif
 
 /* These take the mm semaphore themselves */
index 3e086b073624e8248af19aef5902e56f624f4432..55686fc8128ee24defefc646d68df0e8bf97ce82 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1411,6 +1411,26 @@ long populate_vma_page_range(struct vm_area_struct *vma,
                                NULL, NULL, locked);
 }
 
+/*
+ * mm_populate_vma() - Populate a single range in a single vma.
+ * @vma: The vma to populate.
+ * @start: The start address to populate
+ * @end: The end address to stop populating
+ *
+ * Note: Ignores errors.
+ */
+void mm_populate_vma(struct vm_area_struct *vma, unsigned long start,
+               unsigned long end)
+{
+       struct mm_struct *mm = current->mm;
+       int locked = 1;
+
+       mmap_read_lock(mm);
+       populate_vma_page_range(vma, start, end, &locked);
+       if (locked)
+               mmap_read_unlock(mm);
+}
+
 /*
  * __mm_populate - populate and/or mlock pages within a range of address space.
  *