]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mmap: Add do_mas_munmap() and wraper for __do_munmap()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 24 Nov 2020 19:50:43 +0000 (14:50 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 5 Jan 2021 17:33:26 +0000 (12:33 -0500)
To avoid extra tree work, it is necessary to support passing in a maple state
to key functions.  Start this work with __do_munmap().

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
mm/mmap.c

index bbf3bf1d0b3143be50dcf07b00e66e4284aadb04..dd1eb5bcc13d7fba6e928e5521847c84e56156ed 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2426,17 +2426,18 @@ static inline int unlock_range(struct vm_area_struct *start,
 
        return count;
 }
+
 /* Munmap is split into 2 main parts -- this part which finds
  * what needs doing, and the areas themselves, which do the
  * work.  This now handles partial unmappings.
  * Jeremy Fitzhardinge <jeremy@goop.org>
  */
-int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
-               struct list_head *uf, bool downgrade)
+static int do_mas_munmap(struct ma_state *mas, struct mm_struct *mm,
+                        unsigned long start, size_t len, struct list_head *uf,
+                        bool downgrade)
 {
        unsigned long end;
        struct vm_area_struct *vma, *prev, *last;
-       MA_STATE(mas, &mm->mm_mt, start, start);
 
        if ((offset_in_page(start)) || start > TASK_SIZE || len > TASK_SIZE-start)
                return -EINVAL;
@@ -2449,11 +2450,11 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
        arch_unmap(mm, start, end);
 
        /* Find the first overlapping VMA */
-       vma = mas_find(&mas, end - 1);
+       vma = mas_find(mas, end - 1);
        if (!vma)
                return 0;
 
-       mas.last = end - 1;
+       mas->last = end - 1;
        /* we have start < vma->vm_end  */
 
        /*
@@ -2478,8 +2479,8 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
                        return error;
                prev = vma;
                vma = vma_next(mm, prev);
-               mas.index = start;
-               mas_reset(&mas);
+               mas->index = start;
+               mas_reset(mas);
        } else {
                prev = vma->vm_prev;
        }
@@ -2495,7 +2496,7 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
                if (error)
                        return error;
                vma = vma_next(mm, prev);
-               mas_reset(&mas);
+               mas_reset(mas);
        }
 
 
@@ -2522,7 +2523,7 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
         */
        mm->map_count -= unlock_range(vma, &last, end);
        /* Drop removed area from the tree */
-       mas_store_gfp(&mas, NULL, GFP_KERNEL);
+       mas_store_gfp(mas, NULL, GFP_KERNEL);
 
        /* Detach vmas from the MM linked list */
        vma->vm_prev = NULL;
@@ -2559,6 +2560,13 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
        return downgrade ? 1 : 0;
 }
 
+int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
+               struct list_head *uf, bool downgrade)
+{
+       MA_STATE(mas, &mm->mm_mt, start, start);
+       return do_mas_munmap(&mas, mm, start, len, uf, downgrade);
+}
+
 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
              struct list_head *uf)
 {