]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Drop range_has_overlap() function maple_v5.15-rc3_mmap_lock
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 18 Jun 2021 19:06:12 +0000 (15:06 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 22 Oct 2021 00:27:53 +0000 (20:27 -0400)
Since there is no longer a linked list, the range_has_overlap() function
is identical to the find_vma_intersection() function.  There is only one
place that actually needs the previous vma, so just use vma_prev() in
that one case.

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

index 51150c2cd4c93eb545c6722991da75c19fd05974..0e287c163bd191d5a8eed961f3275103d9c20923 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -433,30 +433,6 @@ anon_vma_interval_tree_post_update_vma(struct vm_area_struct *vma)
                anon_vma_interval_tree_insert(avc, &avc->anon_vma->rb_root);
 }
 
-/*
- * range_has_overlap() - Check the @start - @end range for overlapping VMAs and
- * sets up a pointer to the previous VMA
- * @mm: the mm struct
- * @start: the start address of the range
- * @end: the end address of the range
- * @pprev: the pointer to the pointer of the previous VMA
- *
- * Returns: True if there is an overlapping VMA, false otherwise
- */
-static inline
-bool range_has_overlap(struct mm_struct *mm, unsigned long start,
-                      unsigned long end, struct vm_area_struct **pprev)
-{
-       struct vm_area_struct *existing;
-
-       MA_STATE(mas, &mm->mm_mt, start, start);
-       rcu_read_lock();
-       existing = mas_find(&mas, end - 1);
-       *pprev = mas_prev(&mas, 0);
-       rcu_read_unlock();
-       return existing ? true : false;
-}
-
 /*
  * count_vma_pages_range() - Count the number of pages in a range.
  * @mas: The maple state
@@ -3224,9 +3200,7 @@ oomed:
  */
 int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
 {
-       struct vm_area_struct *prev;
-
-       if (range_has_overlap(mm, vma->vm_start, vma->vm_end, &prev))
+       if (find_vma_intersection(mm, vma->vm_start, vma->vm_end))
                return -ENOMEM;
 
        if ((vma->vm_flags & VM_ACCOUNT) &&
@@ -3265,7 +3239,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
        struct vm_area_struct *vma = *vmap;
        unsigned long vma_start = vma->vm_start;
        struct mm_struct *mm = vma->vm_mm;
-       struct vm_area_struct *new_vma, *prev;
+       struct vm_area_struct *new_vma;
+       struct vm_area_struct *prev;
        bool faulted_in_anon_vma = true;
 
        validate_mm_mt(mm);
@@ -3278,9 +3253,10 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
                faulted_in_anon_vma = false;
        }
 
-       if (range_has_overlap(mm, addr, addr + len, &prev))
+       if (find_vma_intersection(mm, addr, addr + len))
                return NULL;    /* should never get here */
 
+       prev = vma_prev(mm, vma);
        new_vma = vma_merge(mm, prev, addr, addr + len, vma->vm_flags,
                            vma->anon_vma, vma->vm_file, pgoff, vma_policy(vma),
                            vma->vm_userfaultfd_ctx);