This is a note to let you know that I've just added the patch titled mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg to the 5.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-memcontrol-correct-the-nr_anon_thps-counter-of-hi.patch and it can be found in the queue-5.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit d12f5cc12212b466bb5612e7a826a94bb12d1451 Author: zhongjiang-ali <zhongjiang-ali@xxxxxxxxxxxxxxxxx> Date: Sun Nov 1 17:07:30 2020 -0800 mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg [ Upstream commit 7de2e9f195b9cb27583c5c64deaaf5e6afcc163e ] 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@xxxxxxxxxxxxxxxxxxxx: fix printk warning] [akpm@xxxxxxxxxxxxxxxxxxxx: use u64 cast, per Michal] Fixes: 468c398233da ("mm: memcontrol: switch to native NR_ANON_THPS counter") Signed-off-by: zhongjiang-ali <zhongjiang-ali@xxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Link: https://lkml.kernel.org/r/1603722395-72443-1-git-send-email-zhongjiang-ali@xxxxxxxxxxxxxxxxx Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/mm/memcontrol.c b/mm/memcontrol.c index de51787831728..51ce5d172855a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4068,11 +4068,17 @@ static int memcg_stat_show(struct seq_file *m, void *v) (u64)memsw * PAGE_SIZE); for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) { + unsigned long nr; + if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account()) continue; + nr = memcg_page_state(memcg, memcg1_stats[i]); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (memcg1_stats[i] == NR_ANON_THPS) + nr *= HPAGE_PMD_NR; +#endif seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i], - (u64)memcg_page_state(memcg, memcg1_stats[i]) * - PAGE_SIZE); + (u64)nr * PAGE_SIZE); } for (i = 0; i < ARRAY_SIZE(memcg1_events); i++)