]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: Introduce vma_next() and vma_prev()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 4 Jan 2021 20:13:14 +0000 (15:13 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 2 Sep 2021 15:26:27 +0000 (11:26 -0400)
Rename internal vma_next() to _vma_next().

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

index 61f3ba6efbfddfc903218682297c126e1df24277..95b5f1ee47e4fe635cdf946e74c2aef4839e6d26 100644 (file)
@@ -2784,6 +2784,18 @@ struct vm_area_struct *vma_lookup(struct mm_struct *mm, unsigned long addr)
        return mtree_load(&mm->mm_mt, addr);
 }
 
+static inline struct vm_area_struct *vma_next(struct mm_struct *mm,
+                       const struct vm_area_struct *vma)
+{
+       return mt_next(&mm->mm_mt, vma->vm_end - 1, ULONG_MAX);
+}
+
+static inline struct vm_area_struct *vma_prev(struct mm_struct *mm,
+                       const struct vm_area_struct *vma)
+{
+       return mt_prev(&mm->mm_mt, vma->vm_start, 0);
+}
+
 static inline unsigned long vm_start_gap(struct vm_area_struct *vma)
 {
        unsigned long vm_start = vma->vm_start;
index 2c8e2a697a526580485d13691446635d1d1d2785..63477e0e3b67efb7b5fc487af9a5f61726965758 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -485,7 +485,7 @@ bool range_has_overlap(struct mm_struct *mm, unsigned long start,
 }
 
 /*
- * vma_next() - Get the next VMA.
+ * _vma_next() - Get the next VMA or the first.
  * @mm: The mm_struct.
  * @vma: The current vma.
  *
@@ -493,7 +493,7 @@ bool range_has_overlap(struct mm_struct *mm, unsigned long start,
  *
  * Returns: The next VMA after @vma.
  */
-static inline struct vm_area_struct *vma_next(struct mm_struct *mm,
+static inline struct vm_area_struct *_vma_next(struct mm_struct *mm,
                                         struct vm_area_struct *vma)
 {
        if (!vma)
@@ -1182,7 +1182,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
        if (vm_flags & VM_SPECIAL)
                return NULL;
 
-       next = vma_next(mm, prev);
+       next = _vma_next(mm, prev);
        area = next;
        if (area && area->vm_end == end)                /* cases 6, 7, 8 */
                next = next->vm_next;
@@ -2341,7 +2341,7 @@ static void unmap_region(struct mm_struct *mm,
                struct vm_area_struct *vma, struct vm_area_struct *prev,
                unsigned long start, unsigned long end)
 {
-       struct vm_area_struct *next = vma_next(mm, prev);
+       struct vm_area_struct *next = _vma_next(mm, prev);
        struct mmu_gather tlb;
 
        lru_add_drain();
@@ -2495,7 +2495,7 @@ do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
                if (error)
                        return error;
                prev = vma;
-               vma = vma_next(mm, prev);
+               vma = _vma_next(mm, prev);
                mas->index = start;
                mas_reset(mas);
        } else {
@@ -2512,7 +2512,7 @@ do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
                int error = __split_vma(mm, last, end, 1);
                if (error)
                        return error;
-               vma = vma_next(mm, prev);
+               vma = _vma_next(mm, prev);
                mas_reset(mas);
        }