• Minchan Kim's avatar
    mm: /proc/pid/smaps:: show proportional swap share of the mapping · 8334b962
    Minchan Kim authored
    We want to know per-process workingset size for smart memory management
    on userland and we use swap(ex, zram) heavily to maximize memory
    efficiency so workingset includes swap as well as RSS.
    
    On such system, if there are lots of shared anonymous pages, it's really
    hard to figure out exactly how many each process consumes memory(ie, rss
    + wap) if the system has lots of shared anonymous memory(e.g, android).
    
    This patch introduces SwapPss field on /proc/<pid>/smaps so we can get
    more exact workingset size per process.
    
    Bongkyu tested it. Result is below.
    
    1. 50M used swap
    SwapTotal: 461976 kB
    SwapFree: 411192 kB
    
    $ adb shell cat /proc/*/smaps | grep "SwapPss:" | awk '{sum += $2} END {print sum}';
    48236
    $ adb shell cat /proc/*/smaps | grep "Swap:" | awk '{sum += $2} END {print sum}';
    141184
    
    2. 240M used swap
    SwapTotal: 461976 kB
    SwapFree: 216808 kB
    
    $ adb shell cat /proc/*/smaps | grep "SwapPss:" | awk '{sum += $2} END {print sum}';
    230315
    $ adb shell cat /proc/*/smaps | grep "Swap:" | awk '{sum += $2} END {print sum}';
    1387744
    
    [akpm@linux-foundation.org: simplify kunmap_atomic() call]
    Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
    Reported-by: default avatarBongkyu Kim <bongkyu.kim@lge.com>
    Tested-by: default avatarBongkyu Kim <bongkyu.kim@lge.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Jerome Marchand <jmarchan@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    8334b962
swapfile.c 77.7 KB