linux-stable/fs/proc
KOSAKI Motohiro 1c2499ae87 /proc/pid/smaps: fix dirty pages accounting
Currently, /proc/<pid>/smaps has wrong dirty pages accounting.
Shared_Dirty and Private_Dirty output only pte dirty pages and ignore
PG_dirty page flag.  It is difference against documentation, but also
inconsistent against Referenced field.  (Referenced checks both pte and
page flags)

This patch fixes it.

Test program:

 large-array.c
 ---------------------------------------------------
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>

 char array[1*1024*1024*1024L];

 int main(void)
 {
         memset(array, 1, sizeof(array));
         pause();

         return 0;
 }
 ---------------------------------------------------

Test case:
 1. run ./large-array
 2. cat /proc/`pidof large-array`/smaps
 3. swapoff -a
 4. cat /proc/`pidof large-array`/smaps again

Test result:
 <before patch>

00601000-40601000 rw-p 00000000 00:00 0
Size:            1048576 kB
Rss:             1048576 kB
Pss:             1048576 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:    218992 kB   <-- showed pages as clean incorrectly
Private_Dirty:    829584 kB
Referenced:       388364 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB

 <after patch>

00601000-40601000 rw-p 00000000 00:00 0
Size:            1048576 kB
Rss:             1048576 kB
Pss:             1048576 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:   1048576 kB  <-- fixed
Referenced:       388480 kB
Swap:                  0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-09-22 17:22:39 -07:00
..
Kconfig proc: move PROC_PAGE_MONITOR to fs/proc/Kconfig 2008-10-10 04:18:57 +04:00
Makefile procfs: simplify conditional processing of fs/proc.o. 2010-08-11 08:59:20 -07:00
array.c CRED: Fix get_task_cred() and task_state() to not resurrect dead credentials 2010-07-29 15:16:17 -07:00
base.c vfs: show unreachable paths in getcwd and proc 2010-08-11 00:29:47 -04:00
cmdline.c proc: switch /proc/cmdline to seq_file 2008-10-23 14:29:04 +04:00
cpuinfo.c proc: move /proc/cpuinfo code to fs/proc/cpuinfo.c 2008-10-23 15:05:11 +04:00
devices.c proc: move /proc/devices code to fs/proc/devices.c 2008-10-23 15:02:18 +04:00
generic.c remove inode_setattr 2010-08-09 16:47:37 -04:00
inode.c bkl: Remove locked .ioctl file operation 2010-08-14 00:24:24 +02:00
internal.h proc: rename de_get() to pde_get() and inline it 2009-12-16 07:19:57 -08:00
interrupts.c proc: move /proc/interrupts boilerplate code to fs/proc/interrupts.c 2008-10-23 15:15:46 +04:00
kcore.c kcore: add _text to KCORE_TEXT 2010-05-27 09:12:47 -07:00
kmsg.c procfs: Use generic_file_llseek in /proc/kmsg 2010-04-09 16:35:41 +02:00
loadavg.c sched, timers: cleanup avenrun users 2009-05-15 15:32:45 +02:00
meminfo.c hwpoison: fix/proc/meminfo alignment 2009-10-29 07:39:25 -07:00
mmu.c fs/proc/mmu.c: headers butchery 2007-10-17 08:42:48 -07:00
nommu.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
page.c proc: export uncached bit properly in /proc/kpageflags 2010-09-09 18:57:23 -07:00
proc_devtree.c of: Drop properties with "/" in their name 2010-06-13 18:12:24 -06:00
proc_net.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
proc_sysctl.c remove inode_setattr 2010-08-09 16:47:37 -04:00
proc_tty.c proc tty: remove struct tty_operations::read_proc 2009-04-01 08:59:10 -07:00
root.c proc: cleanup: remove unused assignments 2010-05-27 09:12:47 -07:00
softirqs.c proc: export statistics for softirq to /proc 2009-06-18 13:03:41 -07:00
stat.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
task_mmu.c /proc/pid/smaps: fix dirty pages accounting 2010-09-22 17:22:39 -07:00
task_nommu.c nommu: add '[stack]' label to /proc/pid/maps output 2010-06-29 15:29:30 -07:00
uptime.c [PATCH] Fix idle time field in /proc/uptime 2009-09-24 10:16:24 +02:00
version.c proc: switch /proc/version to seq_file 2008-10-23 14:19:58 +04:00
vmcore.c /proc/vmcore: fix seeking 2010-09-22 17:22:38 -07:00