From: Liam R. Howlett Date: Fri, 28 Apr 2023 00:05:21 +0000 (-0400) Subject: mm: Change do_mas_align_munmap() allocation behaviour X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f9a68f9e13d3e795e1e0ee57cc9621dfdc6fe095;p=users%2Fjedix%2Flinux-maple.git mm: Change do_mas_align_munmap() allocation behaviour 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 --- diff --git a/mm/mmap.c b/mm/mmap.c index 14ca259189b7..29aa7509dbf7 100644 --- 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