]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Remove vma_mas_szero() helper
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 19 Aug 2022 17:40:21 +0000 (13:40 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 19 Aug 2022 17:42:08 +0000 (13:42 -0400)
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 <Liam.Howlett@oracle.com>
mm/mmap.c

index 19b7de1ac21207c982b382d7986e5c16f44bf037..97a422165a9adf6a84f766ca01291ea73090d66d 100644 (file)
--- 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;