From: Liam R. Howlett Date: Tue, 24 Nov 2020 21:27:58 +0000 (-0500) Subject: mmap: Remove __do_munmap() in favour of do_mas_munmap() X-Git-Tag: howlett/maple_spf/20210120~46 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=74614c2826eae8fbe4f7a41916904b7a7932f999;p=users%2Fjedix%2Flinux-maple.git mmap: Remove __do_munmap() in favour of do_mas_munmap() Export new interface and use it in place of old interface. Signed-off-by: Liam R. Howlett --- diff --git a/include/linux/mm.h b/include/linux/mm.h index 0f970ed0a619..47626ea2fd22 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -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); diff --git a/mm/mmap.c b/mm/mmap.c index e49f71792c95..ad7bb333fe36 100644 --- 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; } diff --git a/mm/mremap.c b/mm/mremap.c index a488eb3d1447..6e3a4bcea83b 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -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;