]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: Change do_mas_align_munmap() allocation behaviour
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 28 Apr 2023 00:05:21 +0000 (20:05 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 1 May 2023 23:35:05 +0000 (19:35 -0400)
munmap does not need to preallocate maple tree nodes.  In fact, it
already does allocate maple tree nodes for the side branch as well as
VMAs, so it is safe to do so for the tree.  Using the in-tree allocation
allows for a higher chance of better calculation of nodes needed, and
performs better.

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

index 14ca259189b7753e5cac579e349ed31970bd934a..29aa7509dbf71034540b64ceb360a419c7b6b6e2 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2349,9 +2349,6 @@ do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
        mt_init_flags(&mt_detach, mas->tree->ma_flags & MT_FLAGS_LOCK_MASK);
        mt_set_external_lock(&mt_detach, &mm->mmap_lock);
 
-       if (mas_preallocate(mas, vma, GFP_KERNEL))
-               return -ENOMEM;
-
        mas->last = end - 1;
        /*
         * If we need to split any vma, do it now to save pain later.
@@ -2463,7 +2460,7 @@ do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
                mas_set_range(mas, start, end - 1);
        }
 #endif
-       mas_store_prealloc(mas, NULL);
+       mas_store_gfp(mas, NULL, GFP_KERNEL);
        mm->map_count -= count;
        /*
         * Do not downgrade mmap_lock if we are next to VM_GROWSDOWN or