diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/mremap.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mm/mremap.c b/mm/mremap.c index f4e562098500..318eea5467a0 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -245,6 +245,7 @@ unsigned long do_mremap(unsigned long addr, | |||
245 | unsigned long old_len, unsigned long new_len, | 245 | unsigned long old_len, unsigned long new_len, |
246 | unsigned long flags, unsigned long new_addr) | 246 | unsigned long flags, unsigned long new_addr) |
247 | { | 247 | { |
248 | struct mm_struct *mm = current->mm; | ||
248 | struct vm_area_struct *vma; | 249 | struct vm_area_struct *vma; |
249 | unsigned long ret = -EINVAL; | 250 | unsigned long ret = -EINVAL; |
250 | unsigned long charged = 0; | 251 | unsigned long charged = 0; |
@@ -285,7 +286,7 @@ unsigned long do_mremap(unsigned long addr, | |||
285 | if ((addr <= new_addr) && (addr+old_len) > new_addr) | 286 | if ((addr <= new_addr) && (addr+old_len) > new_addr) |
286 | goto out; | 287 | goto out; |
287 | 288 | ||
288 | ret = do_munmap(current->mm, new_addr, new_len); | 289 | ret = do_munmap(mm, new_addr, new_len); |
289 | if (ret) | 290 | if (ret) |
290 | goto out; | 291 | goto out; |
291 | } | 292 | } |
@@ -296,7 +297,7 @@ unsigned long do_mremap(unsigned long addr, | |||
296 | * do_munmap does all the needed commit accounting | 297 | * do_munmap does all the needed commit accounting |
297 | */ | 298 | */ |
298 | if (old_len >= new_len) { | 299 | if (old_len >= new_len) { |
299 | ret = do_munmap(current->mm, addr+new_len, old_len - new_len); | 300 | ret = do_munmap(mm, addr+new_len, old_len - new_len); |
300 | if (ret && old_len != new_len) | 301 | if (ret && old_len != new_len) |
301 | goto out; | 302 | goto out; |
302 | ret = addr; | 303 | ret = addr; |
@@ -309,7 +310,7 @@ unsigned long do_mremap(unsigned long addr, | |||
309 | * Ok, we need to grow.. or relocate. | 310 | * Ok, we need to grow.. or relocate. |
310 | */ | 311 | */ |
311 | ret = -EFAULT; | 312 | ret = -EFAULT; |
312 | vma = find_vma(current->mm, addr); | 313 | vma = find_vma(mm, addr); |
313 | if (!vma || vma->vm_start > addr) | 314 | if (!vma || vma->vm_start > addr) |
314 | goto out; | 315 | goto out; |
315 | if (is_vm_hugetlb_page(vma)) { | 316 | if (is_vm_hugetlb_page(vma)) { |
@@ -325,14 +326,14 @@ unsigned long do_mremap(unsigned long addr, | |||
325 | } | 326 | } |
326 | if (vma->vm_flags & VM_LOCKED) { | 327 | if (vma->vm_flags & VM_LOCKED) { |
327 | unsigned long locked, lock_limit; | 328 | unsigned long locked, lock_limit; |
328 | locked = current->mm->locked_vm << PAGE_SHIFT; | 329 | locked = mm->locked_vm << PAGE_SHIFT; |
329 | lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; | 330 | lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; |
330 | locked += new_len - old_len; | 331 | locked += new_len - old_len; |
331 | ret = -EAGAIN; | 332 | ret = -EAGAIN; |
332 | if (locked > lock_limit && !capable(CAP_IPC_LOCK)) | 333 | if (locked > lock_limit && !capable(CAP_IPC_LOCK)) |
333 | goto out; | 334 | goto out; |
334 | } | 335 | } |
335 | if (!may_expand_vm(current->mm, (new_len - old_len) >> PAGE_SHIFT)) { | 336 | if (!may_expand_vm(mm, (new_len - old_len) >> PAGE_SHIFT)) { |
336 | ret = -ENOMEM; | 337 | ret = -ENOMEM; |
337 | goto out; | 338 | goto out; |
338 | } | 339 | } |
@@ -359,11 +360,10 @@ unsigned long do_mremap(unsigned long addr, | |||
359 | vma_adjust(vma, vma->vm_start, | 360 | vma_adjust(vma, vma->vm_start, |
360 | addr + new_len, vma->vm_pgoff, NULL); | 361 | addr + new_len, vma->vm_pgoff, NULL); |
361 | 362 | ||
362 | current->mm->total_vm += pages; | 363 | mm->total_vm += pages; |
363 | vm_stat_account(vma->vm_mm, vma->vm_flags, | 364 | vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages); |
364 | vma->vm_file, pages); | ||
365 | if (vma->vm_flags & VM_LOCKED) { | 365 | if (vma->vm_flags & VM_LOCKED) { |
366 | current->mm->locked_vm += pages; | 366 | mm->locked_vm += pages; |
367 | make_pages_present(addr + old_len, | 367 | make_pages_present(addr + old_len, |
368 | addr + new_len); | 368 | addr + new_len); |
369 | } | 369 | } |