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

Submitted by Andrey Ryabinin on Jan. 23, 2017, 10:15 a.m.

Details

Message ID 20170123101549.20250-1-aryabinin@virtuozzo.com
State New
Series "mm/memcontrol: Fix mem cgroup usage statistics."
Headers show

Commit Message

Andrey Ryabinin Jan. 23, 2017, 10:15 a.m.
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;