• K
    /proc/pid/smaps: fix dirty pages accounting · 1c2499ae
    KOSAKI Motohiro 提交于
    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: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Acked-by: NHugh Dickins <hughd@google.com>
    Cc: Matt Mackall <mpm@selenic.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    1c2499ae
task_mmu.c 20.5 KB