From: Liam R. Howlett Date: Tue, 2 May 2023 00:26:34 +0000 (-0400) Subject: mm/mmap: Fix mas_preallocate() limits in various places X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3f45bc5b9bdfdd30ee2bee4a36cf438604384fc6;p=users%2Fjedix%2Flinux-maple.git mm/mmap: Fix mas_preallocate() limits in various places Fix the maple state setup prior to calling mas_preallocate() in a few functions. This will help with node estimates later. Signed-off-by: Liam R. Howlett --- diff --git a/mm/mmap.c b/mm/mmap.c index 077a10bfc8b8b..5ea97c037ab2d 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -469,7 +469,7 @@ static inline void vma_mas_szero(struct ma_state *mas, unsigned long start, static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma) { - MA_STATE(mas, &mm->mm_mt, 0, 0); + MA_STATE(mas, &mm->mm_mt, vma->vm_start, vma->vm_end - 1); struct address_space *mapping = NULL; if (mas_preallocate(&mas, vma, GFP_KERNEL)) @@ -538,6 +538,7 @@ inline int vma_expand(struct ma_state *mas, struct vm_area_struct *vma, /* Only handles expanding */ VM_BUG_ON(vma->vm_start < start || vma->vm_end > end); + mas_set_range(mas, start, end - 1); if (mas_preallocate(mas, vma, GFP_KERNEL)) goto nomem; @@ -1951,7 +1952,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address) struct vm_area_struct *next; unsigned long gap_addr; int error = 0; - MA_STATE(mas, &mm->mm_mt, 0, 0); + MA_STATE(mas, &mm->mm_mt, vma->vm_start, address - 1); if (!(vma->vm_flags & VM_GROWSUP)) return -EFAULT; @@ -1976,6 +1977,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address) /* Check that both stack segments have the same anon_vma? */ } + mas->last = address - 1; if (mas_preallocate(&mas, vma, GFP_KERNEL)) return -ENOMEM; @@ -2057,6 +2059,7 @@ int expand_downwards(struct vm_area_struct *vma, unsigned long address) return -ENOMEM; } + mas_set_range(&mas, address, vma->vm_end - 1); if (mas_preallocate(&mas, vma, GFP_KERNEL)) return -ENOMEM; @@ -2812,7 +2815,7 @@ static int __vm_munmap(unsigned long start, size_t len, bool downgrade) int ret; struct mm_struct *mm = current->mm; LIST_HEAD(uf); - MA_STATE(mas, &mm->mm_mt, start, start); + MA_STATE(mas, &mm->mm_mt, start, start + len); if (mmap_write_lock_killable(mm)) return -EINTR;