The patch titled Subject: mm: memcg/slab: fix root memcg vmstats has been added to the -mm tree. Its filename is mm-memcg-slab-fix-root-memcg-vmstats.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memcg-slab-fix-root-memcg-vmstats.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcg-slab-fix-root-memcg-vmstats.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Muchun Song <songmuchun@xxxxxxxxxxxxx> Subject: mm: memcg/slab: fix root memcg vmstats If we reparent the slab objects to the root memcg, when we free the slab object, we need to update the per-memcg vmstats to keep it correct for the root memcg. Now this at least affects the vmstat of NR_KERNEL_STACK_KB for !CONFIG_VMAP_STACK when the thread stack size is smaller than the PAGE_SIZE. Link: https://lkml.kernel.org/r/20201110031015.15715-1-songmuchun@xxxxxxxxxxxxx Fixes: ec9f02384f60 ("mm: workingset: fix vmstat counters for shadow nodes") Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Acked-by: Roman Gushchin <guro@xxxxxx> Reviewed-by: Shakeel Butt <shakeelb@xxxxxxxxxx> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Cc: Christopher Lameter <cl@xxxxxxxxx> Cc: Pekka Enberg <penberg@xxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Roman Gushchin <guro@xxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Yafang Shao <laoar.shao@xxxxxxxxx> Cc: Chris Down <chris@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/mm/memcontrol.c~mm-memcg-slab-fix-root-memcg-vmstats +++ a/mm/memcontrol.c @@ -853,8 +853,13 @@ void __mod_lruvec_slab_state(void *p, en rcu_read_lock(); memcg = mem_cgroup_from_obj(p); - /* Untracked pages have no memcg, no lruvec. Update only the node */ - if (!memcg || memcg == root_mem_cgroup) { + /* + * Untracked pages have no memcg, no lruvec. Update only the + * node. If we reparent the slab objects to the root memcg, + * when we free the slab object, we need to update the per-memcg + * vmstats to keep it correct for the root memcg. + */ + if (!memcg) { __mod_node_page_state(pgdat, idx, val); } else { lruvec = mem_cgroup_lruvec(memcg, pgdat); _ Patches currently in -mm which might be from songmuchun@xxxxxxxxxxxxx are mm-memcontrol-fix-missing-wakeup-polling-thread.patch mm-memcontrol-remove-unused-mod_memcg_obj_state.patch mm-memcg-slab-fix-return-child-memcg-objcg-for-root-memcg.patch mm-memcg-slab-fix-use-after-free-in-obj_cgroup_charge.patch mm-memcg-slab-fix-root-memcg-vmstats.patch