• M
    mm: /proc/pid/smaps:: show proportional swap share of the mapping · 8334b962
    Minchan Kim 提交于
    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: NMinchan Kim <minchan@kernel.org>
    Reported-by: NBongkyu Kim <bongkyu.kim@lge.com>
    Tested-by: NBongkyu 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: NAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    8334b962
proc.txt 84.8 KB