]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mmap: Remove __do_munmap() in favour of do_mas_munmap()
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 24 Nov 2020 21:27:58 +0000 (16:27 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 20 Jan 2021 14:28:15 +0000 (09:28 -0500)
Export new interface and use it in place of old interface.

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

index 0f970ed0a61915a7a8bdf41634e43e0760c28a4c..47626ea2fd221773eacc5c9737317a70c7b41cb0 100644 (file)
@@ -2574,8 +2574,8 @@ extern unsigned long mmap_region(struct file *file, unsigned long addr,
 extern unsigned long do_mmap(struct file *file, unsigned long addr,
        unsigned long len, unsigned long prot, unsigned long flags,
        unsigned long pgoff, unsigned long *populate, struct list_head *uf);
-extern int __do_munmap(struct mm_struct *, unsigned long, size_t,
-                      struct list_head *uf, bool downgrade);
+extern int do_mas_munmap(struct ma_state *mas, struct mm_struct *mm,
+        unsigned long start, size_t len, struct list_head *uf, bool downgrade);
 extern int do_munmap(struct mm_struct *, unsigned long, size_t,
                     struct list_head *uf);
 extern int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behavior);
index e49f71792c95bc65f6f0302117b8657927984825..ad7bb333fe36c75732249fce267587faff51dade 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2574,13 +2574,6 @@ int do_mas_align_munmap(struct ma_state *mas, struct vm_area_struct *vma,
        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);
-}
-
 /*
  * do_mas_munmap() - munmap a given range.
  * @mas: The maple state
@@ -2629,7 +2622,8 @@ int do_mas_munmap(struct ma_state *mas, struct mm_struct *mm,
 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
              struct list_head *uf)
 {
-       return __do_munmap(mm, start, len, uf, false);
+       MA_STATE(mas, &mm->mm_mt, start, start);
+       return do_mas_munmap(&mas, mm, start, len, uf, false);
 }
 
 unsigned long mmap_region(struct file *file, unsigned long addr,
@@ -2877,11 +2871,12 @@ 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);
 
        if (mmap_write_lock_killable(mm))
                return -EINTR;
 
-       ret = __do_munmap(mm, start, len, &uf, downgrade);
+       ret = do_mas_munmap(&mas, mm, start, len, &uf, downgrade);
        /*
         * Returning 1 indicates mmap_lock is downgraded.
         * But 1 is not legal return value of vm_munmap() and munmap(), reset
@@ -3034,9 +3029,6 @@ static int do_brk_munmap(struct ma_state *mas, struct vm_area_struct *vma,
        arch_unmap(mm, newbrk, oldbrk);
 
        if (likely(vma->vm_start >= newbrk)) { // remove entire mapping(s)
-               mas_set(mas, newbrk);
-               if (vma->vm_start != newbrk)
-                       mas_reset(mas); // cause a re-walk for the first overlap.
                ret = do_mas_munmap(mas, mm, newbrk, oldbrk-newbrk, uf, true);
                goto munmap_full_vma;
        }
index a488eb3d14473d7e5146a69948da4573d1c6df98..6e3a4bcea83b8b6bc12fc73819b81322f8912e6e 100644 (file)
@@ -872,14 +872,15 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
        /*
         * Always allow a shrinking remap: that just unmaps
         * the unnecessary pages..
-        * __do_munmap does all the needed commit accounting, and
+        * do_mas_munmap does all the needed commit accounting, and
         * downgrades mmap_lock to read if so directed.
         */
        if (old_len >= new_len) {
                int retval;
+               MA_STATE(mas, &mm->mm_mt, addr + new_len, addr + new_len);
 
-               retval = __do_munmap(mm, addr+new_len, old_len - new_len,
-                                 &uf_unmap, true);
+               retval = do_mas_munmap(&mas, mm, addr + new_len,
+                                      old_len - new_len, &uf_unmap, true);
                if (retval < 0 && old_len != new_len) {
                        ret = retval;
                        goto out;