Commit d0de32d9 authored by Hugh Dickins's avatar Hugh Dickins Committed by Linus Torvalds

[PATCH] mm: do_mremap current mm

Cleanup: relieve do_mremap from its surfeit of current->mms.
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9e9bef07
...@@ -245,6 +245,7 @@ unsigned long do_mremap(unsigned long addr, ...@@ -245,6 +245,7 @@ unsigned long do_mremap(unsigned long addr,
unsigned long old_len, unsigned long new_len, unsigned long old_len, unsigned long new_len,
unsigned long flags, unsigned long new_addr) unsigned long flags, unsigned long new_addr)
{ {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma; struct vm_area_struct *vma;
unsigned long ret = -EINVAL; unsigned long ret = -EINVAL;
unsigned long charged = 0; unsigned long charged = 0;
...@@ -285,7 +286,7 @@ unsigned long do_mremap(unsigned long addr, ...@@ -285,7 +286,7 @@ unsigned long do_mremap(unsigned long addr,
if ((addr <= new_addr) && (addr+old_len) > new_addr) if ((addr <= new_addr) && (addr+old_len) > new_addr)
goto out; goto out;
ret = do_munmap(current->mm, new_addr, new_len); ret = do_munmap(mm, new_addr, new_len);
if (ret) if (ret)
goto out; goto out;
} }
...@@ -296,7 +297,7 @@ unsigned long do_mremap(unsigned long addr, ...@@ -296,7 +297,7 @@ unsigned long do_mremap(unsigned long addr,
* do_munmap does all the needed commit accounting * do_munmap does all the needed commit accounting
*/ */
if (old_len >= new_len) { if (old_len >= new_len) {
ret = do_munmap(current->mm, addr+new_len, old_len - new_len); ret = do_munmap(mm, addr+new_len, old_len - new_len);
if (ret && old_len != new_len) if (ret && old_len != new_len)
goto out; goto out;
ret = addr; ret = addr;
...@@ -309,7 +310,7 @@ unsigned long do_mremap(unsigned long addr, ...@@ -309,7 +310,7 @@ unsigned long do_mremap(unsigned long addr,
* Ok, we need to grow.. or relocate. * Ok, we need to grow.. or relocate.
*/ */
ret = -EFAULT; ret = -EFAULT;
vma = find_vma(current->mm, addr); vma = find_vma(mm, addr);
if (!vma || vma->vm_start > addr) if (!vma || vma->vm_start > addr)
goto out; goto out;
if (is_vm_hugetlb_page(vma)) { if (is_vm_hugetlb_page(vma)) {
...@@ -325,14 +326,14 @@ unsigned long do_mremap(unsigned long addr, ...@@ -325,14 +326,14 @@ unsigned long do_mremap(unsigned long addr,
} }
if (vma->vm_flags & VM_LOCKED) { if (vma->vm_flags & VM_LOCKED) {
unsigned long locked, lock_limit; unsigned long locked, lock_limit;
locked = current->mm->locked_vm << PAGE_SHIFT; locked = mm->locked_vm << PAGE_SHIFT;
lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
locked += new_len - old_len; locked += new_len - old_len;
ret = -EAGAIN; ret = -EAGAIN;
if (locked > lock_limit && !capable(CAP_IPC_LOCK)) if (locked > lock_limit && !capable(CAP_IPC_LOCK))
goto out; goto out;
} }
if (!may_expand_vm(current->mm, (new_len - old_len) >> PAGE_SHIFT)) { if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
...@@ -359,11 +360,10 @@ unsigned long do_mremap(unsigned long addr, ...@@ -359,11 +360,10 @@ unsigned long do_mremap(unsigned long addr,
vma_adjust(vma, vma->vm_start, vma_adjust(vma, vma->vm_start,
addr + new_len, vma->vm_pgoff, NULL); addr + new_len, vma->vm_pgoff, NULL);
current->mm->total_vm += pages; mm->total_vm += pages;
vm_stat_account(vma->vm_mm, vma->vm_flags, vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
vma->vm_file, pages);
if (vma->vm_flags & VM_LOCKED) { if (vma->vm_flags & VM_LOCKED) {
current->mm->locked_vm += pages; mm->locked_vm += pages;
make_pages_present(addr + old_len, make_pages_present(addr + old_len,
addr + new_len); addr + new_len);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment