[PATCH v11 51/69] mm/gup: use maple tree navigation instead of linked list

Liam Howlett liam.howlett at oracle.com
Sat Jul 16 19:46:54 PDT 2022

From: "Liam R. Howlett" <Liam.Howlett at Oracle.com>

Use find_vma_intersection() to locate the VMAs in __mm_populate() instead
of using find_vma() and the linked list.

Link: https://lkml.kernel.org/r/20220504011345.662299-36-Liam.Howlett@oracle.com
Link: https://lkml.kernel.org/r/20220621204632.3370049-52-Liam.Howlett@oracle.com
Signed-off-by: Liam R. Howlett <Liam.Howlett at Oracle.com>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: David Howells <dhowells at redhat.com>
Cc: "Matthew Wilcox (Oracle)" <willy at infradead.org>
Cc: SeongJae Park <sj at kernel.org>
Cc: Vlastimil Babka <vbabka at suse.cz>
Cc: Will Deacon <will at kernel.org>
Cc: Davidlohr Bueso <dave at stgolabs.net>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
 mm/gup.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/gup.c b/mm/gup.c
index 407a81d5ca03..f0e5d68ea932 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1641,10 +1641,11 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
 		if (!locked) {
 			locked = 1;
-			vma = find_vma(mm, nstart);
+			vma = find_vma_intersection(mm, nstart, end);
 		} else if (nstart >= vma->vm_end)
-			vma = vma->vm_next;
-		if (!vma || vma->vm_start >= end)
+			vma = find_vma_intersection(mm, vma->vm_end, end);
+		if (!vma)
 		 * Set [nstart; nend) to intersection of desired address

More information about the maple-tree mailing list