• Hugh Dickins's avatar
    [PATCH] statm: shared = rss - anon_rss · 8586febd
    Hugh Dickins authored
    The third "shared" field of /proc/$pid/statm in 2.4 was a count of pages in
    the mm whose page_count is more than 1 (oddly, including pages shared just
    with swapcache).  That's too costly to calculate each time, so 2.6 changed
    it to the total file-backed extent.  But Andrea knows apps and users
    surprised when (rss - shared) goes negative: we need to provide an rss-like
    statistic, close to the 2.4 interpretation.
    
    Something that's quick and easy to maintain accurately is mm->anon_rss, the
    count of anonymous pages in the mm.  Then shared = rss - anon_rss gives a
    pretty good and meaningful approximation to 2.4's intention: wli confirms
    that this will be useful to Oracle too.
    
    Where to show it?  I think it's best to treat this as a bugfix and show it
    in the third field of /proc/$pid/statm, after resident, as before - there's
    no evidence that the total file-backed extent was found useful.
    
    Albert would like other fields to revert to page counts, but that's a lot
    harder: if mprotect can change the category of a page, then it can't be
    accounted as simply as this.  Only go that route if real need shown.
    Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
    Acked-by: default avatarWilliam Irwin <wli@holomorphy.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    8586febd
sched.h 33.8 KB