]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
madvise: Use vmi iterator for __split_vma() and vma_merge()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Thu, 10 Nov 2022 18:02:10 +0000 (13:02 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 13 Dec 2022 20:58:35 +0000 (15:58 -0500)
Use the vma iterator so that the iterator can be invalidated or updated
to avoid each caller doing so.

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

index b913ba6efc10beb7e60b0a4851b68ca6f47f2af3..98615628d7e870328ec3167404780ac7160dfe39 100644 (file)
@@ -145,6 +145,7 @@ static int madvise_update_vma(struct vm_area_struct *vma,
        struct mm_struct *mm = vma->vm_mm;
        int error;
        pgoff_t pgoff;
+       VMA_ITERATOR(vmi, mm, 0);
 
        if (new_flags == vma->vm_flags && anon_vma_name_eq(anon_vma_name(vma), anon_name)) {
                *prev = vma;
@@ -152,8 +153,8 @@ static int madvise_update_vma(struct vm_area_struct *vma,
        }
 
        pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
-       *prev = vma_merge(mm, *prev, start, end, new_flags, vma->anon_vma,
-                         vma->vm_file, pgoff, vma_policy(vma),
+       *prev = vmi_vma_merge(&vmi, mm, *prev, start, end, new_flags,
+                         vma->anon_vma, vma->vm_file, pgoff, vma_policy(vma),
                          vma->vm_userfaultfd_ctx, anon_name);
        if (*prev) {
                vma = *prev;
@@ -165,7 +166,7 @@ static int madvise_update_vma(struct vm_area_struct *vma,
        if (start != vma->vm_start) {
                if (unlikely(mm->map_count >= sysctl_max_map_count))
                        return -ENOMEM;
-               error = __split_vma(mm, vma, start, 1);
+               error = vmi__split_vma(&vmi, mm, vma, start, 1);
                if (error)
                        return error;
        }
@@ -173,7 +174,7 @@ static int madvise_update_vma(struct vm_area_struct *vma,
        if (end != vma->vm_end) {
                if (unlikely(mm->map_count >= sysctl_max_map_count))
                        return -ENOMEM;
-               error = __split_vma(mm, vma, end, 0);
+               error = vmi__split_vma(&vmi, mm, vma, end, 0);
                if (error)
                        return error;
        }