]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mremap: use vma_find_intersection() instead of vma linked list
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 20 Jul 2022 02:18:02 +0000 (02:18 +0000)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 6 Sep 2022 19:44:25 +0000 (15:44 -0400)
Using the vma_find_intersection() call allows for cleaner code and
removes linked list users in preparation of the linked list removal.

Also remove one user of the linked list at the same time in favour of
find_vma().

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
mm/mremap.c

index e0fba90042466d415323155b928782629ad3e04f..8644ff278f02989a910811d4a95aa0b2f26d96c5 100644 (file)
@@ -716,7 +716,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
        if (excess) {
                vma->vm_flags |= VM_ACCOUNT;
                if (split)
-                       vma->vm_next->vm_flags |= VM_ACCOUNT;
+                       find_vma(mm, vma->vm_end)->vm_flags |= VM_ACCOUNT;
        }
 
        return new_addr;
@@ -866,9 +866,10 @@ out:
 static int vma_expandable(struct vm_area_struct *vma, unsigned long delta)
 {
        unsigned long end = vma->vm_end + delta;
+
        if (end < vma->vm_end) /* overflow */
                return 0;
-       if (vma->vm_next && vma->vm_next->vm_start < end) /* intersection */
+       if (find_vma_intersection(vma->vm_mm, vma->vm_end, end))
                return 0;
        if (get_unmapped_area(NULL, vma->vm_start, end - vma->vm_start,
                              0, MAP_FIXED) & ~PAGE_MASK)