From f9a68f9e13d3e795e1e0ee57cc9621dfdc6fe095 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 27 Apr 2023 20:05:21 -0400 Subject: [PATCH] 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 --- mm/mmap.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 -- 2.50.1