From: Liam R. Howlett Date: Fri, 19 Aug 2022 17:40:21 +0000 (-0400) Subject: mm/mmap: Remove vma_mas_szero() helper X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fc53e340546613eedaf132d249fece95da430381;p=users%2Fjedix%2Flinux-maple.git mm/mmap: Remove vma_mas_szero() helper Remove the helper to zero out a portion of a VMA. It is only called from one function and putting the logic in that function allows for a WARN_ON() to be added to check for a logic error. Signed-off-by: Liam R. Howlett --- diff --git a/mm/mmap.c b/mm/mmap.c index 19b7de1ac212..97a422165a9a 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -435,22 +435,6 @@ void vma_mas_store(struct vm_area_struct *vma, struct ma_state *mas) mas_store_prealloc(mas, vma); } -/* - * vma_mas_szero() - Set a given range to zero. Used when modifying a - * vm_area_struct start or end. - * - * @mm: The struct_mm - * @start: The start address to zero - * @end: The end address to zero. - */ -static inline void vma_mas_szero(struct ma_state *mas, unsigned long start, - unsigned long end) -{ - trace_vma_mas_szero(mas->tree, start, end - 1); - mas_set_range(mas, start, end - 1); - mas_store_prealloc(mas, NULL); -} - static int vma_link(struct mm_struct *mm, struct vm_area_struct *vma) { MA_STATE(mas, &mm->mm_mt, 0, 0); @@ -738,14 +722,19 @@ int vma_shrink(struct ma_state *mas, struct vm_area_struct *vma, lock_vma(&vma_lock); if (vma->vm_start < start) - vma_mas_szero(mas, vma->vm_start, start); + mas_set_range(mas, vma->vm_start, start - 1); - if (vma->vm_end > end) - vma_mas_szero(mas, end, vma->vm_end); + if (vma->vm_end > end) { + WARN_ON(vma->vm_start < start); + mas_set_range(mas, end, vma->vm_end - 1); + } vma->vm_start = start; vma->vm_end = end; vma->vm_pgoff = pgoff; + trace_vma_mas_szero(mas->tree, mas->index, mas->last); + mas_store_prealloc(mas, NULL); + unlock_vma(&vma_lock, mas, vma->vm_mm); validate_mm(vma->vm_mm); return 0;