[Devel,RHEL7,COMMIT] mm/memcontrol: Fix mem cgroup usage statistics.

Submitted by Konstantin Khorenko on Jan. 23, 2017, 10:47 a.m.

Details

Message ID 201701231047.v0NAltXK031548@finist_cl7.x64_64.work.ct
State New
Series "mm/memcontrol: Fix mem cgroup usage statistics."
Headers show

Commit Message

Konstantin Khorenko Jan. 23, 2017, 10:47 a.m.
The commit is pushed to "branch-rh7-3.10.0-514.6.1.vz7.28.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.6.1.vz7.28.2
------>
commit 7e9a740f1e974b0a5d8236824c060ece43a59865
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Mon Jan 23 14:47:55 2017 +0400

    mm/memcontrol: Fix mem cgroup usage statistics.
    
    mem_cgroup_usage() reports usage in pages for non-root cgroup, and in bytes
    otherwise. Make it always in pages and update mem_cgroup_read() caller
    which wants result in bytes.
    
    https://jira.sw.ru/browse/PSBM-58993
    
    Fixes: 1af99077c135 ("ms/mm: memcontrol: revert use of root_mem_cgroup res_counter")
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/memcontrol.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index dc83f4e..233f542 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4194,7 +4194,7 @@  static inline u64 mem_cgroup_usage(struct mem_cgroup *memcg, bool swap)
 	if (swap)
 		val += mem_cgroup_recursive_stat(memcg, MEM_CGROUP_STAT_SWAP);
 
-	return val << PAGE_SHIFT;
+	return val;
 }
 
 void mem_cgroup_fill_meminfo(struct mem_cgroup *memcg, struct meminfo *mi)
@@ -4268,9 +4268,9 @@  static ssize_t mem_cgroup_read(struct cgroup *cont, struct cftype *cft,
 	switch (MEMFILE_ATTR(cft->private)) {
 	case RES_USAGE:
 		if (counter == &memcg->memory)
-			val = mem_cgroup_usage(memcg, false);
+			val = mem_cgroup_usage(memcg, false) * PAGE_SIZE;
 		else if (counter == &memcg->memsw)
-			val = mem_cgroup_usage(memcg, true);
+			val = mem_cgroup_usage(memcg, true) * PAGE_SIZE;
 		else
 			val = (u64)page_counter_read(counter) * PAGE_SIZE;
 		break;