mm: memcg: account memory used for memcg vmstats and lruvec stats
authorRoman Gushchin <roman.gushchin@linux.dev>
Wed, 1 May 2024 17:26:12 +0000 (10:26 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 7 May 2024 17:36:59 +0000 (10:36 -0700)
The percpu memory used by memcg's memory statistics is already accounted.
For consistency, let's enable accounting for vmstats and lruvec stats as
well.

Link: https://lkml.kernel.org/r/20240501172617.678560-4-shakeel.butt@linux.dev
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: T.J. Mercier <tjmercier@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memcontrol.c

index cf6819a3310dd1323eefee7b3a0429e1f95eb8ec..42e0062d880b7fb742faf56663addac0e8e0e2ae 100644 (file)
@@ -5540,8 +5540,8 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
        if (!pn)
                return 1;
 
-       pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL,
-                                       node);
+       pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats),
+                                       GFP_KERNEL_ACCOUNT, node);
        if (!pn->lruvec_stats)
                goto fail;
 
@@ -5612,7 +5612,8 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent)
                goto fail;
        }
 
-       memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats), GFP_KERNEL);
+       memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats),
+                                GFP_KERNEL_ACCOUNT);
        if (!memcg->vmstats)
                goto fail;