kernel-ark/fs
David Rientjes b813e931b4 smaps: add clear_refs file to clear reference
Adds /proc/pid/clear_refs.  When any non-zero number is written to this file,
pte_mkold() and ClearPageReferenced() is called for each pte and its
corresponding page, respectively, in that task's VMAs.  This file is only
writable by the user who owns the task.

It is now possible to measure _approximately_ how much memory a task is using
by clearing the reference bits with

	echo 1 > /proc/pid/clear_refs

and checking the reference count for each VMA from the /proc/pid/smaps output
at a measured time interval.  For example, to observe the approximate change
in memory footprint for a task, write a script that clears the references
(echo 1 > /proc/pid/clear_refs), sleeps, and then greps for Pgs_Referenced and
extracts the size in kB.  Add the sizes for each VMA together for the total
referenced footprint.  Moments later, repeat the process and observe the
difference.

For example, using an efficient Mozilla:

	accumulated time		referenced memory
	----------------		-----------------
		 0 s				 408 kB
		 1 s				 408 kB
		 2 s				 556 kB
		 3 s				1028 kB
		 4 s				 872 kB
		 5 s				1956 kB
		 6 s				 416 kB
		 7 s				1560 kB
		 8 s				2336 kB
		 9 s				1044 kB
		10 s				 416 kB

This is a valuable tool to get an approximate measurement of the memory
footprint for a task.

Cc: Hugh Dickins <hugh@veritas.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: David Rientjes <rientjes@google.com>
[akpm@linux-foundation.org: build fixes]
[mpm@selenic.com: rename for_each_pmd]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-07 12:12:52 -07:00
..
9p
adfs
affs
afs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
autofs
autofs4
befs
bfs
cifs [CIFS] Fix typo in cifs readme from previous commit 2007-05-05 22:08:06 +00:00
coda
configfs remove "struct subsystem" as it is no longer needed 2007-05-02 18:57:59 -07:00
cramfs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
debugfs remove "struct subsystem" as it is no longer needed 2007-05-02 18:57:59 -07:00
devpts
dlm remove "struct subsystem" as it is no longer needed 2007-05-02 18:57:59 -07:00
ecryptfs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
efs
exportfs
ext2 mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
ext3
ext4
fat
freevxfs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
fuse remove "struct subsystem" as it is no longer needed 2007-05-02 18:57:59 -07:00
gfs2 remove "struct subsystem" as it is no longer needed 2007-05-02 18:57:59 -07:00
hfs
hfsplus
hostfs
hpfs
hppfs
hugetlbfs proper prototype for hugetlb_get_unmapped_area() 2007-05-07 12:12:51 -07:00
isofs
jbd
jbd2
jffs2
jfs
lockd
minix mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
msdos
ncpfs
nfs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
nfs_common
nfsd
nls
ntfs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
ocfs2 mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
openpromfs
partitions mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
proc smaps: add clear_refs file to clear reference 2007-05-07 12:12:52 -07:00
qnx4
ramfs
reiserfs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
romfs
smbfs
sysfs remove "struct subsystem" as it is no longer needed 2007-05-02 18:57:59 -07:00
sysv mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
udf
ufs mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
vfat
xfs
aio.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf_fdpic.c
binfmt_elf.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
binfmt_som.c
bio.c
block_dev.c
buffer.c fs: buffer don't PageUptodate without page locked 2007-05-07 12:12:51 -07:00
char_dev.c
compat_ioctl.c [PATCH] x86-64: Shut up warnings for vfat compat ioctls on other file systems 2007-05-02 19:27:21 +02:00
compat.c [PATCH] x86-64: Print type and size correctly for unknown compat ioctls 2007-05-02 19:27:21 +02:00
dcache.c
dcookies.c
direct-io.c
dnotify.c
dquot.c
drop_caches.c
eventpoll.c
exec.c
fcntl.c
fifo.c
file_table.c
file.c
filesystems.c
fs-writeback.c
generic_acl.c
inode.c
inotify_user.c
inotify.c
internal.h
ioctl.c
ioprio.c
Kconfig Merge git://git.linux-nfs.org/pub/linux/nfs-2.6 2007-05-04 19:55:11 -07:00
Kconfig.binfmt
libfs.c
locks.c
Makefile
mbcache.c
mpage.c
namei.c mm: make read_cache_page synchronous 2007-05-07 12:12:51 -07:00
namespace.c
nfsctl.c
no-block.c
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
quota_v1.c
quota_v2.c
quota.c
read_write.c
read_write.h
readdir.c
select.c
seq_file.c
splice.c
stack.c
stat.c
super.c
sync.c
utimes.c
xattr_acl.c
xattr.c