Skip to content

Commit 9f45717

Browse files
hnaztorvalds
authored andcommitted
mm: memcontrol: fix warning when allocating the root cgroup
Commit 3e38e0a ("mm: memcg: charge memcg percpu memory to the parent cgroup") adds memory tracking to the memcg kernel structures themselves to make cgroups liable for the memory they are consuming through the allocation of child groups (which can be significant). This code is a bit awkward as it's spread out through several functions: The outermost function does memalloc_use_memcg(parent) to set up current->active_memcg, which designates which cgroup to charge, and the inner functions pass GFP_ACCOUNT to request charging for specific allocations. To make sure this dependency is satisfied at all times - to make sure we don't randomly charge whoever is calling the functions - the inner functions warn on !current->active_memcg. However, this triggers a false warning when the root memcg itself is allocated. No parent exists in this case, and so current->active_memcg is rightfully NULL. It's a false positive, not indicative of a bug. Delete the warnings for now, we can revisit this later. Fixes: 3e38e0a ("mm: memcg: charge memcg percpu memory to the parent cgroup") Signed-off-by: Johannes Weiner <[email protected]> Reported-by: Stephen Rothwell <[email protected]> Acked-by: Roman Gushchin <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent dc06fe5 commit 9f45717

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

mm/memcontrol.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5137,9 +5137,6 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
51375137
if (!pn)
51385138
return 1;
51395139

5140-
/* We charge the parent cgroup, never the current task */
5141-
WARN_ON_ONCE(!current->active_memcg);
5142-
51435140
pn->lruvec_stat_local = alloc_percpu_gfp(struct lruvec_stat,
51445141
GFP_KERNEL_ACCOUNT);
51455142
if (!pn->lruvec_stat_local) {
@@ -5222,9 +5219,6 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
52225219
goto fail;
52235220
}
52245221

5225-
/* We charge the parent cgroup, never the current task */
5226-
WARN_ON_ONCE(!current->active_memcg);
5227-
52285222
memcg->vmstats_local = alloc_percpu_gfp(struct memcg_vmstats_percpu,
52295223
GFP_KERNEL_ACCOUNT);
52305224
if (!memcg->vmstats_local)

0 commit comments

Comments
 (0)