mm/util.c: make vm_memory_committed() more accurate

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: Feng Tang <>
Signed-off-by: Andrew Morton <>
Acked-by: Michal Hocko <> # for /proc/meminfo
Cc: "K. Y. Srinivasan" <>
Cc: Haiyang Zhang <>
Cc: Matthew Wilcox (Oracle) <>
Cc: Johannes Weiner <>
Cc: Mel Gorman <>
Cc: Qian Cai <>
Cc: Andi Kleen <>
Cc: Tim Chen <>
Cc: Dave Hansen <>
Cc: Huang Ying <>
Cc: Christoph Lameter <>
Cc: Dennis Zhou <>
Cc: Kees Cook <>
Cc: kernel test robot <>
Cc: Tejun Heo <>
Signed-off-by: Linus Torvalds <>
1 file changed