Skip to contentSkip to conversation

mm-use-maple-tree-operations-for-find_vma_intersection.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Sep 27, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm: use maple tree operations for find_vma_intersection()
has been removed from the -mm tree. Its filename was
mm-use-maple-tree-operations-for-find_vma_intersection.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: "Liam R. Howlett" <[email protected]>
Subject: mm: use maple tree operations for find_vma_intersection()
Date: Tue, 6 Sep 2022 19:48:50 +0000

Move find_vma_intersection() to mmap.c and change implementation to maple tree.

When searching for a vma within a range, it is easier to use the maple tree interface.

Exported find_vma_intersection() for kvm module.

Cc Catalin Marinas <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc David Howells <[email protected]>
Cc Davidlohr Bueso <[email protected]>
Cc "Matthew Wilcox (Oracle)" <[email protected]>
Cc SeongJae Park <[email protected]>
Cc Sven Schnelle <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Will Deacon <[email protected]>

---

 include/linux/mm.h |   22 ++++------------------
 mm/mmap.c          |   29 +++++++++++++++++++++++++++++
 mm/nommu.c         |   11 +++++++++++
 3 files changed, 44 insertions(+), 18 deletions(-)
include/linux/mm.h renamed from include/linux/mm.h~mm-use-maple-tree-operations-for-find_vma_intersection +4 -18
@@ -2778,26 +2778,12 @@ extern struct vm_area_struct * find_vma(
 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
 					     struct vm_area_struct **pprev);
 
-/**
- * find_vma_intersection() - Look up the first VMA which intersects the interval
- * @mm: The process address space.
- * @start_addr: The inclusive start user address.
- * @end_addr: The exclusive end user address.
- *
- * Returns: The first VMA within the provided range, %NULL otherwise.  Assumes
- * start_addr < end_addr.
+/*
+ * Look up the first VMA which intersects the interval [start_addr, end_addr)
+ * NULL if none.  Assume start_addr < end_addr.
  */
-static inline
 struct vm_area_struct *find_vma_intersection(struct mm_struct *mm,
-					     unsigned long start_addr,
-					     unsigned long end_addr)
-{
-	struct vm_area_struct *vma = find_vma(mm, start_addr);
-
-	if (vma && end_addr <= vma->vm_start)
-		vma = NULL;
-	return vma;
-}
+			unsigned long start_addr, unsigned long end_addr);
 
 /**
  * vma_lookup() - Find a VMA at a specific address
mm/mmap.c renamed from mm/mmap.c~mm-use-maple-tree-operations-for-find_vma_intersection +29 -0
@@ -2062,6 +2062,35 @@ get_unmapped_area(struct file *file, uns
 EXPORT_SYMBOL(get_unmapped_area);
 
 /**
+ * find_vma_intersection() - Look up the first VMA which intersects the interval
+ * @mm: The process address space.
+ * @start_addr: The inclusive start user address.
+ * @end_addr: The exclusive end user address.
+ *
+ * Returns: The first VMA within the provided range, %NULL otherwise.  Assumes
+ * start_addr < end_addr.
+ */
+struct vm_area_struct *find_vma_intersection(struct mm_struct *mm,
+					     unsigned long start_addr,
+					     unsigned long end_addr)
+{
+	struct vm_area_struct *vma;
+	unsigned long index = start_addr;
+
+	mmap_assert_locked(mm);
+	/* Check the cache first. */
+	vma = vmacache_find(mm, start_addr);
+	if (likely(vma))
+		return vma;
+
+	vma = mt_find(&mm->mm_mt, &index, end_addr - 1);
+	if (vma)
+		vmacache_update(start_addr, vma);
+	return vma;
+}
+EXPORT_SYMBOL(find_vma_intersection);
+
+/**
  * find_vma() - Find the VMA for a given address, or the next VMA.
  * @mm: The mm_struct to check
  * @addr: The address
mm/nommu.c renamed from mm/nommu.c~mm-use-maple-tree-operations-for-find_vma_intersection +11 -0
@@ -642,6 +642,17 @@ static void delete_vma(struct mm_struct
 	vm_area_free(vma);
 }
 
+struct vm_area_struct *find_vma_intersection(struct mm_struct *mm,
+					     unsigned long start_addr,
+					     unsigned long end_addr)
+{
+	unsigned long index = start_addr;
+
+	mmap_assert_locked(mm);
+	return mt_find(&mm->mm_mt, &index, end_addr - 1);
+}
+EXPORT_SYMBOL(find_vma_intersection);
+
 /*
  * look up the first VMA in which addr resides, NULL if none
  * - should be called with mm->mmap_lock at least held readlocked

_

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