]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Optimize case 6 in __vma_adjust()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 21 Apr 2022 17:11:36 +0000 (13:11 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 21 Apr 2022 22:34:52 +0000 (18:34 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
mm/mmap.c

index dbfd3576b6d0ab96c63c51ea432d9289154c9ea7..01dd9af0b13eeb284f2464fc1c62e03030ff0747 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -641,7 +641,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
        struct vm_area_struct *expand)
 {
        struct mm_struct *mm = vma->vm_mm;
-       struct vm_area_struct *next = find_vma(mm, vma->vm_end);
+       struct vm_area_struct *next_next, *next = find_vma(mm, vma->vm_end);
        struct vm_area_struct *orig_vma = vma;
        struct address_space *mapping = NULL;
        struct rb_root_cached *root = NULL;
@@ -682,8 +682,9 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
                                 * remove_next == 1 is case 1 or 7.
                                 */
                                remove_next = 1 + (end > next->vm_end);
+                               next_next = find_vma(mm, next->vm_end);
                                VM_WARN_ON(remove_next == 2 &&
-                                          end != find_vma(mm, next->vm_end)->vm_end);
+                                          end != next_next->vm_end);
                                /* trim end to next, for case 6 first pass */
                                end = next->vm_end;
                        }
@@ -863,7 +864,7 @@ again:
                         * "next->prev->vm_end" changed and the
                         * "vma->next" gap must be updated.
                         */
-                       next = find_vma(mm, vma->vm_end);
+                       next = next_next;
                } else {
                        /*
                         * For the scope of the comment "next" and
@@ -878,6 +879,7 @@ again:
                        next = vma;
                }
                if (remove_next == 2) {
+                       vma_changed = false;
                        remove_next = 1;
                        end = next->vm_end;
                        goto again;