shmem: fix shared anonymous accounting
authorHugh Dickins <hugh@veritas.com>
Tue, 24 Feb 2009 20:51:52 +0000 (20:51 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 25 Feb 2009 20:21:42 +0000 (12:21 -0800)
commit0b0a0806b0d8635e046bf533225a25903b1cddce
tree245ac39eb1b7c6008a669ab2d68ed174d66bd7bc
parentc15d8a6499d04e5d2cac07f8120f207bb275f60f
shmem: fix shared anonymous accounting

Each time I exit Firefox, /proc/meminfo's Committed_AS goes down almost
400 kB: OVERCOMMIT_NEVER would be allowing overcommits it should
prohibit.

Commit fc8744adc870a8d4366908221508bb113d8b72ee "Stop playing silly
games with the VM_ACCOUNT flag" changed shmem_file_setup() to set the
shmem file's VM_ACCOUNT flag according to VM_NORESERVE not being set in
the vma flags; but did so only _after_ the shmem_acct_size(flags, size)
call which is expected to pre-account a shared anonymous object.

It's all clearer if we switch shmem.c over to use VM_NORESERVE
throughout in place of !VM_ACCOUNT.

But I very nearly sent in a patch which mistakenly removed the
accounting from tmpfs files: shmem_get_inode()'s memset was good for not
setting VM_ACCOUNT, but now it needs to set VM_NORESERVE.

Rather than setting that by default, then perhaps clearing it again in
shmem_file_setup(), let's pass it as a flag to shmem_get_inode(): that
allows us to remove the #ifdef CONFIG_SHMEM from shmem_file_setup().

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/shmem.c