All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] statm: __vm_stat_accounting
@ 2004-10-24 15:45 Hugh Dickins
  2004-10-24 15:46 ` [PATCH 2/3] statm: fix negative data Hugh Dickins
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Hugh Dickins @ 2004-10-24 15:45 UTC (permalink / raw)
  To: Andrew Morton; +Cc: William Irwin, linux-kernel

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: Hugh Dickins <hugh@veritas.com>
---
 mm/mmap.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

--- 2.6.10-rc1/mm/mmap.c	2004-10-23 12:44:13.000000000 +0100
+++ linux/mm/mmap.c	2004-10-23 20:43:24.000000000 +0100
@@ -988,9 +988,12 @@ munmap_back:
 	 *         f_op->mmap method. -DaveM
 	 */
 	addr = vma->vm_start;
+	pgoff = vma->vm_pgoff;
+	vm_flags = vma->vm_flags;
 
 	if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
 			vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
+		file = vma->vm_file;
 		vma_link(mm, vma, prev, rb_link, rb_parent);
 		if (correct_wcount)
 			atomic_inc(&inode->i_writecount);
@@ -1005,6 +1008,7 @@ munmap_back:
 	}
 out:	
 	mm->total_vm += len >> PAGE_SHIFT;
+	__vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
 	if (vm_flags & VM_LOCKED) {
 		mm->locked_vm += len >> PAGE_SHIFT;
 		make_pages_present(addr, addr + len);
@@ -1015,7 +1019,6 @@ out:	
 					pgoff, flags & MAP_NONBLOCK);
 		down_write(&mm->mmap_sem);
 	}
-	__vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
 	return addr;
 
 unmap_and_free_vma:


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-10-25 19:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-24 15:45 [PATCH 1/3] statm: __vm_stat_accounting Hugh Dickins
2004-10-24 15:46 ` [PATCH 2/3] statm: fix negative data Hugh Dickins
2004-10-24 16:08   ` William Lee Irwin III
2004-10-24 15:49 ` [PATCH 3/3] statm: shared = rss - anon_rss Hugh Dickins
2004-10-24 16:08   ` William Lee Irwin III
2004-10-25  6:24     ` Andrew Morton
2004-10-25  6:29       ` William Lee Irwin III
2004-10-25 19:30   ` William Lee Irwin III
2004-10-25 19:48     ` Andrea Arcangeli
2004-10-24 16:08 ` [PATCH 1/3] statm: __vm_stat_accounting William Lee Irwin III

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.