The commit is pushed to "branch-rh8-4.18.0-193.6.3.vz8.4.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-193.6.3.vz8.4.9
------>
commit 9dc4432ee111848013875a98d6e594c336655255
Author: Roman Gushchin <[email protected]>
Date:   Tue Aug 11 18:30:25 2020 -0700

    ms/mm: memcg: charge memcg percpu memory to the parent cgroup
    
    Memory cgroups are using large chunks of percpu memory to store vmstat
    data.  Yet this memory is not accounted at all, so in the case when there
    are many (dying) cgroups, it's not exactly clear where all the memory is.
    
    Because the size of memory cgroup internal structures can dramatically
    exceed the size of object or page which is pinning it in the memory, it's
    not a good idea to simply ignore it.  It actually breaks the isolation
    between cgroups.
    
    Let's account the consumed percpu memory to the parent cgroup.
    
    [[email protected]: add WARN_ON_ONCE()s, per Johannes]
      Link: 
http://lkml.kernel.org/r/[email protected]
    
    Signed-off-by: Roman Gushchin <[email protected]>
    Signed-off-by: Andrew Morton <[email protected]>
    Reviewed-by: Shakeel Butt <[email protected]>
    Acked-by: Dennis Zhou <[email protected]>
    Acked-by: Johannes Weiner <[email protected]>
    Cc: Christoph Lameter <[email protected]>
    Cc: David Rientjes <[email protected]>
    Cc: Joonsoo Kim <[email protected]>
    Cc: Mel Gorman <[email protected]>
    Cc: Michal Hocko <[email protected]>
    Cc: Pekka Enberg <[email protected]>
    Cc: Tejun Heo <[email protected]>
    Cc: Tobin C. Harding <[email protected]>
    Cc: Vlastimil Babka <[email protected]>
    Cc: Waiman Long <[email protected]>
    Cc: Bixuan Cui <[email protected]>
    Cc: Michal Koutný <[email protected]>
    Cc: Stephen Rothwell <[email protected]>
    Link: http://lkml.kernel.org/r/[email protected]
    Signed-off-by: Linus Torvalds <[email protected]>
    
    (cherry picked from commit 3e38e0aaca9eafb12b1c4b731d1c10975cbe7974)
    + fix commit: 9f457179244a ("mm: memcontrol: fix warning when allocating
    the root cgroup")
    
    Signed-off-by: Konstantin Khorenko <[email protected]>
    Found and suggested by Vasily Averin <[email protected]>
    
    Backport notices:
    * pn->lruvec_stat_local hunk dropped
    * memcg->vmstats_percpu is called memcg->stat_cpu in vz8
    * memcg->vmstats_local hunk dropped
---
 mm/memcontrol.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 68242a72be4d..ff751ca90562 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4973,7 +4973,8 @@ static int alloc_mem_cgroup_per_node_info(struct 
mem_cgroup *memcg, int node)
        if (!pn)
                return 1;
 
-       pn->lruvec_stat_cpu = alloc_percpu(struct lruvec_stat);
+       pn->lruvec_stat_cpu = alloc_percpu_gpf(struct lruvec_stat,
+                                              GFP_KERNEL_ACCOUNT);
        if (!pn->lruvec_stat_cpu) {
                kfree(pn);
                return 1;
@@ -5034,7 +5035,8 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
        if (memcg->id.id < 0)
                goto fail;
 
-       memcg->stat_cpu = alloc_percpu(struct mem_cgroup_stat_cpu);
+       memcg->stat_cpu = alloc_percpu_gpf(struct mem_cgroup_stat_cpu,
+                                          GFP_KERNEL_ACCOUNT);
        if (!memcg->stat_cpu)
                goto fail;
 
@@ -5075,7 +5077,9 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state 
*parent_css)
        struct mem_cgroup *memcg;
        long error = -ENOMEM;
 
+       memalloc_use_memcg(parent);
        memcg = mem_cgroup_alloc();
+       memalloc_unuse_memcg();
        if (!memcg)
                return ERR_PTR(error);
 
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to