• Feng Tang's avatar
    mm/util.c: make vm_memory_committed() more accurate · 4e2ee51e
    Feng Tang authored
    percpu_counter_sum_positive() will provide more accurate info.
    
    As with percpu_counter_read_positive(), in worst case the deviation could
    be 'batch * nr_cpus', which is totalram_pages/256 for now, and will be
    more when the batch gets enlarged.
    
    Its time cost is about 800 nanoseconds on a 2C/4T platform and 2~3
    microseconds on a 2S/36C/72T Skylake server in normal case, and in worst
    case where vm_committed_as's spinlock is under severe contention, it costs
    30~40 microseconds for the 2S/36C/72T Skylake sever, which should be fine
    for its only two users: /proc/meminfo and HyperV balloon driver's status
    trace per second.
    Signed-off-by: default avatarFeng Tang <feng.tang@intel.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Acked-by: Michal Hocko <mhocko@suse.com> # for /proc/meminfo
    Cc: "K. Y. Srinivasan" <kys@microsoft.com>
    Cc: Haiyang Zhang <haiyangz@microsoft.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Qian Cai <cai@lca.pw>
    Cc: Andi Kleen <andi.kleen@intel.com>
    Cc: Tim Chen <tim.c.chen@intel.com>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Huang Ying <ying.huang@intel.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Dennis Zhou <dennis@kernel.org>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: kernel test robot <rong.a.chen@intel.com>
    Cc: Tejun Heo <tj@kernel.org>
    Link: http://lkml.kernel.org/r/1592725000-73486-3-git-send-email-feng.tang@intel.com
    Link: http://lkml.kernel.org/r/1594389708-60781-3-git-send-email-feng.tang@intel.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    4e2ee51e
util.c 22.7 KB