[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b49f38c5-7544-c297-6198-6ec20852d043@openvz.org>
Date: Mon, 13 Jun 2022 08:35:33 +0300
From: Vasily Averin <vvs@...nvz.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: kernel@...nvz.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, Shakeel Butt <shakeelb@...gle.com>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Michal Koutný <mkoutny@...e.com>,
Vlastimil Babka <vbabka@...e.cz>,
Michal Hocko <mhocko@...e.com>,
Muchun Song <songmuchun@...edance.com>, cgroups@...r.kernel.org
Subject: [PATCH mm v4 7/9] memcg: enable accounting for large allocations in
mem_cgroup_css_alloc
Creation of each memory cgroup allocates few huge objects in
mem_cgroup_css_alloc(). Its size exceeds the size of memory
accounted in common part of cgroup creation:
common part: ~11Kb + 318 bytes percpu
memcg: ~17Kb + 4692 bytes percpu
memory:
------
Allocs Alloc $1*$2 Sum Allocation
number size
--------------------------------------------
1 + 8192 8192 8192 (mem_cgroup_css_alloc+0x4a) <NB
14 ~ 352 4928 13120 KERNFS
1 + 2048 2048 15168 (mem_cgroup_css_alloc+0xdd) <NB
1 1024 1024 16192 (alloc_shrinker_info+0x79)
1 584 584 16776 (radix_tree_node_alloc.constprop.0+0x89)
2 64 128 16904 (percpu_ref_init+0x6a)
1 64 64 16968 (mem_cgroup_css_online+0x32)
1 = 3684 3684 3684 call_site=mem_cgroup_css_alloc+0x9e
1 = 984 984 4668 call_site=mem_cgroup_css_alloc+0xfd
2 12 24 4692 call_site=percpu_ref_init+0x23
'=' -- already accounted,
'+' -- to be accounted,
'~' -- partially accounted
Accounting for this memory helps to avoid misuse inside memcg-limited
contianers.
Signed-off-by: Vasily Averin <vvs@...nvz.org>
Reviewed-by: Roman Gushchin <roman.gushchin@...ux.dev>
Reviewed-by: Michal Koutný <mkoutny@...e.com>
Acked-by: Shakeel Butt <shakeelb@...gle.com>
Reviewed-by: Muchun Song <songmuchun@...edance.com>
---
mm/memcontrol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 27cebaa53472..a8647a8417e4 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5086,7 +5086,7 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node)
{
struct mem_cgroup_per_node *pn;
- pn = kzalloc_node(sizeof(*pn), GFP_KERNEL, node);
+ pn = kzalloc_node(sizeof(*pn), GFP_KERNEL_ACCOUNT, node);
if (!pn)
return 1;
@@ -5138,7 +5138,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
int __maybe_unused i;
long error = -ENOMEM;
- memcg = kzalloc(struct_size(memcg, nodeinfo, nr_node_ids), GFP_KERNEL);
+ memcg = kzalloc(struct_size(memcg, nodeinfo, nr_node_ids), GFP_KERNEL_ACCOUNT);
if (!memcg)
return ERR_PTR(error);
--
2.36.1
Powered by blists - more mailing lists