Skip to content

Commit 7de2e9f

Browse files
zhongjiang-alitorvalds
authored andcommitted
mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg
memcg_page_state will get the specified number in hierarchical memcg, It should multiply by HPAGE_PMD_NR rather than an page if the item is NR_ANON_THPS. [akpm@linux-foundation.org: fix printk warning] [akpm@linux-foundation.org: use u64 cast, per Michal] Fixes: 468c398 ("mm: memcontrol: switch to native NR_ANON_THPS counter") Signed-off-by: zhongjiang-ali <zhongjiang-ali@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.com> Link: https://lkml.kernel.org/r/1603722395-72443-1-git-send-email-zhongjiang-ali@linux.alibaba.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 79aa925 commit 7de2e9f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

mm/memcontrol.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4110,11 +4110,17 @@ static int memcg_stat_show(struct seq_file *m, void *v)
41104110
(u64)memsw * PAGE_SIZE);
41114111

41124112
for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
4113+
unsigned long nr;
4114+
41134115
if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
41144116
continue;
4117+
nr = memcg_page_state(memcg, memcg1_stats[i]);
4118+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
4119+
if (memcg1_stats[i] == NR_ANON_THPS)
4120+
nr *= HPAGE_PMD_NR;
4121+
#endif
41154122
seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i],
4116-
(u64)memcg_page_state(memcg, memcg1_stats[i]) *
4117-
PAGE_SIZE);
4123+
(u64)nr * PAGE_SIZE);
41184124
}
41194125

41204126
for (i = 0; i < ARRAY_SIZE(memcg1_events); i++)

0 commit comments

Comments
 (0)