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

[PATCH] statm: __vm_stat_accounting

The procfs shared_vm accounting in do_mmap_pgoff didn't balance with munmap
in the case of shared anonymous: because file comes in NULL, whereas
vm_file gets set at the end by shmem_zero_setup.

Update file; and update vm_flags (a driver is likely to add VM_IO or
VM_RESERVED, modifying reserved_vm); and update pgoff (doesn't affect
procfs accounting, but could affect vma_merge - though at present all
drivers which modify vm_pgoff set a VM_SPECIAL which prevents merging). 
And do that __vm_stat_account before advancing to make_pages_present.
Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
Acked-by: default avatarWilliam Irwin <wli@holomorphy.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 64450ca0
...@@ -988,9 +988,12 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, ...@@ -988,9 +988,12 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
* f_op->mmap method. -DaveM * f_op->mmap method. -DaveM
*/ */
addr = vma->vm_start; addr = vma->vm_start;
pgoff = vma->vm_pgoff;
vm_flags = vma->vm_flags;
if (!file || !vma_merge(mm, prev, addr, vma->vm_end, if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) { vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
file = vma->vm_file;
vma_link(mm, vma, prev, rb_link, rb_parent); vma_link(mm, vma, prev, rb_link, rb_parent);
if (correct_wcount) if (correct_wcount)
atomic_inc(&inode->i_writecount); atomic_inc(&inode->i_writecount);
...@@ -1005,6 +1008,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, ...@@ -1005,6 +1008,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
} }
out: out:
mm->total_vm += len >> PAGE_SHIFT; mm->total_vm += len >> PAGE_SHIFT;
__vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
if (vm_flags & VM_LOCKED) { if (vm_flags & VM_LOCKED) {
mm->locked_vm += len >> PAGE_SHIFT; mm->locked_vm += len >> PAGE_SHIFT;
make_pages_present(addr, addr + len); make_pages_present(addr, addr + len);
...@@ -1015,7 +1019,6 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr, ...@@ -1015,7 +1019,6 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
pgoff, flags & MAP_NONBLOCK); pgoff, flags & MAP_NONBLOCK);
down_write(&mm->mmap_sem); down_write(&mm->mmap_sem);
} }
__vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
return addr; return addr;
unmap_and_free_vma: unmap_and_free_vma:
......
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