]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/mremap: Remove vma_adjust() call from mremap.
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 10 May 2022 02:46:56 +0000 (22:46 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 11 May 2022 14:46:53 +0000 (10:46 -0400)
vma_adjust() is called after vma_expandable() ensures the area is
completely empty.  Since this is the trivial expansion case, the
vma_expand() function can be used instead.

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

index 8d9f89e49bd82d84767fa90ee95136980ba23aa3..41ca5b8dbd44fce59aee51698ec10b6394efacfb 100644 (file)
@@ -1016,6 +1016,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
                /* can we just expand the current mapping? */
                if (vma_expandable(vma, new_len - old_len)) {
                        long pages = (new_len - old_len) >> PAGE_SHIFT;
+                       MA_STATE(mas, &mm->mm_mt, vma->vm_start, vma->vm_start);
 
                        if (vma->vm_flags & VM_ACCOUNT) {
                                if (security_vm_enough_memory_mm(mm, pages)) {
@@ -1024,8 +1025,8 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
                                }
                        }
 
-                       if (vma_adjust(vma, vma->vm_start, addr + new_len,
-                                      vma->vm_pgoff, NULL)) {
+                       if (vma_expand(&mas, vma, vma->vm_start, addr + new_len,
+                                      vma->vm_pgoff, vma)) {
                                vm_unacct_memory(pages);
                                ret = -ENOMEM;
                                goto out;