From: Vasily Averin <vvs@openvz.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kernel@openvz.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, "Shakeel Butt" <shakeelb@google.com>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Michal Koutný" <mkoutny@suse.com>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Michal Hocko" <mhocko@suse.com>,
"Muchun Song" <songmuchun@bytedance.com>,
cgroups@vger.kernel.org
Subject: [PATCH mm v4 1/9] memcg: enable accounting for struct cgroup
Date: Mon, 13 Jun 2022 08:34:42 +0300 [thread overview]
Message-ID: <4c393a46-f6cf-ce8a-7771-81cbbc9ca278@openvz.org> (raw)
In-Reply-To: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org>
Creating each new cgroup allocates 4Kb for struct cgroup. This is the
largest memory allocation in this scenario and is epecially important
for small VMs with 1-2 CPUs.
Common part of the cgroup creation:
Allocs Alloc $1*$2 Sum Allocation
number size
--------------------------------------------
16 ~ 352 5632 5632 KERNFS
1 + 4096 4096 9728 (cgroup_mkdir+0xe4)
1 584 584 10312 (radix_tree_node_alloc.constprop.0+0x89)
1 192 192 10504 (__d_alloc+0x29)
2 72 144 10648 (avc_alloc_node+0x27)
2 64 128 10776 (percpu_ref_init+0x6a)
1 64 64 10840 (memcg_list_lru_alloc+0x21a)
percpu:
1 + 192 192 192 call_site=psi_cgroup_alloc+0x1e
1 + 96 96 288 call_site=cgroup_rstat_init+0x5f
2 12 24 312 call_site=percpu_ref_init+0x23
1 6 6 318 call_site=__percpu_counter_init+0x22
'+' -- to be accounted,
'~' -- partially accounted
Accounting of this memory helps to avoid misuse inside memcg-limited
containers.
Signed-off-by: Vasily Averin <vvs@openvz.org>
Reviewed-by: Roman Gushchin <roman.gushchin@linux.dev>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
---
kernel/cgroup/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 90a654cb8a1e..9adf4ad4b623 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -5353,7 +5353,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name,
/* allocate the cgroup and its ID, 0 is reserved for the root */
cgrp = kzalloc(struct_size(cgrp, ancestor_ids, (level + 1)),
- GFP_KERNEL);
+ GFP_KERNEL_ACCOUNT);
if (!cgrp)
return ERR_PTR(-ENOMEM);
--
2.36.1
next prev parent reply other threads:[~2022-06-13 5:36 UTC|newest]
Thread overview: 139+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 10:37 [PATCH] memcg: accounting for objects allocated for new netdevice Vasily Averin
2022-04-27 14:01 ` Michal Koutný
2022-04-27 16:52 ` Shakeel Butt
2022-04-27 22:35 ` Vasily Averin
2022-05-02 12:15 ` [PATCH memcg v2] " Vasily Averin
2022-05-04 20:50 ` Luis Chamberlain
2022-05-05 3:50 ` patchwork-bot+netdevbpf
2022-05-11 2:51 ` Roman Gushchin
2022-05-02 19:37 ` kernfs memcg accounting Vasily Averin
2022-05-02 21:22 ` Michal Koutný
2022-05-04 9:00 ` Vasily Averin
2022-05-04 14:10 ` Michal Koutný
2022-05-04 21:16 ` Vasily Averin
2022-05-05 9:47 ` Michal Koutný
2022-05-06 8:37 ` Vasily Averin
2022-05-11 3:06 ` Roman Gushchin
2022-05-11 6:01 ` Vasily Averin
2022-05-11 16:49 ` Michal Koutný
2022-05-11 17:46 ` Roman Gushchin
2022-05-11 16:34 ` Michal Koutný
2022-05-11 18:10 ` Roman Gushchin
2022-05-13 15:51 ` [PATCH 0/4] memcg: accounting for objects allocated by mkdir cgroup Vasily Averin
2022-05-13 17:49 ` Roman Gushchin
2022-05-21 16:37 ` [PATCH mm v2 0/9] " Vasily Averin
2022-05-30 11:25 ` [PATCH mm v3 " Vasily Averin
2022-05-30 11:55 ` Michal Hocko
2022-05-30 13:09 ` Vasily Averin
2022-05-30 14:22 ` Michal Hocko
2022-05-30 19:58 ` Vasily Averin
2022-05-31 7:16 ` Michal Hocko
2022-06-01 3:43 ` Vasily Averin
2022-06-01 9:15 ` Michal Koutný
2022-06-01 9:32 ` Michal Hocko
2022-06-01 13:05 ` Michal Hocko
2022-06-01 14:22 ` Roman Gushchin
2022-06-01 15:24 ` Michal Hocko
2022-06-01 9:26 ` Michal Hocko
2022-06-13 5:34 ` [PATCH mm v4 " Vasily Averin
2022-06-23 14:50 ` [PATCH mm v5 0/9] memcg: accounting for objects allocated by mkdir, cgroup Vasily Averin
2022-06-23 15:03 ` Vasily Averin
2022-06-23 16:07 ` Michal Hocko
2022-06-23 16:55 ` Shakeel Butt
2022-06-24 10:40 ` Vasily Averin
2022-06-24 12:26 ` Michal Koutný
2022-06-24 13:59 ` Michal Hocko
2022-06-25 9:43 ` [PATCH RFC] memcg: avoid idr ids space depletion Vasily Averin
2022-06-25 14:04 ` [PATCH RFC] memcg: notify about global mem_cgroup_id " Vasily Averin
2022-06-26 1:56 ` Roman Gushchin
2022-06-26 7:11 ` Vasily Averin
2022-06-27 2:12 ` [PATCH cgroup] cgroup: set the correct return code if hierarchy limits are reached Vasily Averin
2022-06-27 3:33 ` Muchun Song
2022-06-27 9:07 ` Tejun Heo
2022-06-28 0:44 ` Roman Gushchin
2022-06-28 3:59 ` Vasily Averin
2022-06-28 9:16 ` Michal Koutný
2022-06-28 9:22 ` Tejun Heo
2022-06-29 6:13 ` Vasily Averin
2022-06-29 19:25 ` Tejun Heo
2022-07-01 2:42 ` Roman Gushchin
2022-06-27 2:11 ` [PATCH mm v2] memcg: notify about global mem_cgroup_id space depletion Vasily Averin
2022-06-27 3:23 ` Muchun Song
2022-06-27 6:49 ` Vasily Averin
2022-06-28 1:11 ` Roman Gushchin
2022-06-28 3:43 ` Vasily Averin
2022-06-28 9:08 ` Michal Koutný
2022-06-27 16:37 ` [PATCH mm v5 0/9] memcg: accounting for objects allocated by mkdir, cgroup Shakeel Butt
2022-07-01 11:03 ` Michal Hocko
2022-07-10 18:53 ` Vasily Averin
2022-07-11 16:24 ` Michal Hocko
2022-06-23 14:50 ` [PATCH mm v5 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-06-23 14:50 ` [PATCH mm v5 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-06-23 14:51 ` [PATCH mm v5 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-06-23 14:51 ` [PATCH mm v5 4/9] memcg: enable accounting for struct simple_xattr Vasily Averin
2022-06-23 14:51 ` [PATCH mm v5 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Vasily Averin
2022-06-23 14:51 ` [PATCH mm v5 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Vasily Averin
2022-06-23 14:51 ` [PATCH mm v5 7/9] memcg: enable accounting for large allocations in mem_cgroup_css_alloc Vasily Averin
2022-06-23 14:51 ` [PATCH mm v5 8/9] memcg: enable accounting for allocations in alloc_fair_sched_group Vasily Averin
2022-06-23 14:52 ` [PATCH mm v5 9/9] memcg: enable accounting for perpu allocation of struct rt_rq Vasily Averin
2022-06-13 5:34 ` Vasily Averin [this message]
2022-06-13 5:34 ` [PATCH mm v4 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-06-13 5:34 ` [PATCH mm v4 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-06-13 5:35 ` [PATCH mm v4 4/9] memcg: enable accounting for struct simple_xattr Vasily Averin
2022-06-13 5:35 ` [PATCH mm v4 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Vasily Averin
2022-06-13 5:35 ` [PATCH mm v4 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Vasily Averin
2022-06-13 5:35 ` [PATCH mm v4 7/9] memcg: enable accounting for large allocations in mem_cgroup_css_alloc Vasily Averin
2022-06-13 5:35 ` [PATCH mm v4 8/9] memcg: enable accounting for allocations in alloc_fair_sched_group Vasily Averin
2022-06-13 5:35 ` [PATCH mm v4 9/9] memcg: enable accounting for perpu allocation of struct rt_rq Vasily Averin
[not found] ` <cover.1653899364.git.vvs@openvz.org>
2022-05-30 11:25 ` [PATCH mm v3 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-05-30 11:26 ` [PATCH mm v3 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-05-30 11:26 ` [PATCH mm v3 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-05-30 11:26 ` [PATCH mm v3 4/9] memcg: enable accounting for struct simple_xattr Vasily Averin
2022-05-30 11:26 ` [PATCH mm v3 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Vasily Averin
2022-05-30 11:26 ` [PATCH mm v3 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Vasily Averin
2022-05-30 15:04 ` Muchun Song
2022-05-30 11:26 ` [PATCH mm v3 7/9] memcg: enable accounting for large allocations in mem_cgroup_css_alloc Vasily Averin
2022-05-30 11:26 ` [PATCH mm v3 8/9] memcg: enable accounting for allocations in alloc_fair_sched_group Vasily Averin
2022-05-30 11:27 ` [PATCH mm v3 9/9] memcg: enable accounting for perpu allocation of struct rt_rq Vasily Averin
2022-05-30 15:06 ` Muchun Song
2022-05-21 16:37 ` [PATCH mm v2 1/9] memcg: enable accounting for struct cgroup Vasily Averin
2022-05-22 6:37 ` Muchun Song
2022-05-21 16:37 ` [PATCH mm v2 2/9] memcg: enable accounting for kernfs nodes Vasily Averin
2022-05-22 6:37 ` Muchun Song
2022-05-21 16:37 ` [PATCH mm v2 3/9] memcg: enable accounting for kernfs iattrs Vasily Averin
2022-05-22 6:38 ` Muchun Song
2022-05-21 16:38 ` [PATCH mm v2 4/9] memcg: enable accounting for struct simple_xattr Vasily Averin
2022-05-22 6:38 ` Muchun Song
2022-05-21 16:38 ` [PATCH mm v2 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu Vasily Averin
2022-05-21 21:34 ` Shakeel Butt
2022-05-22 6:40 ` Muchun Song
2022-05-25 1:30 ` Roman Gushchin
2022-05-21 16:38 ` [PATCH mm v2 6/9] memcg: enable accounting for percpu allocation of struct cgroup_rstat_cpu Vasily Averin
2022-05-21 17:58 ` Vasily Averin
2022-05-21 21:35 ` Shakeel Butt
2022-05-21 22:05 ` kernel test robot
2022-05-25 1:31 ` Roman Gushchin
2022-05-21 16:38 ` [PATCH mm v2 7/9] memcg: enable accounting for large allocations in mem_cgroup_css_alloc Vasily Averin
2022-05-22 6:47 ` Muchun Song
2022-05-21 16:38 ` [PATCH mm v2 8/9] memcg: enable accounting for allocations in alloc_fair_sched_group Vasily Averin
2022-05-22 6:49 ` Muchun Song
2022-05-21 16:39 ` [PATCH mm v2 9/9] memcg: enable accounting for percpu allocation of struct rt_rq Vasily Averin
2022-05-21 21:37 ` Shakeel Butt
2022-05-25 1:31 ` Roman Gushchin
2022-05-13 15:51 ` [PATCH 1/4] memcg: enable accounting for large allocations in mem_cgroup_css_alloc Vasily Averin
2022-05-19 16:46 ` Michal Koutný
2022-05-20 1:07 ` Shakeel Butt
2022-05-13 15:51 ` [PATCH 2/4] memcg: enable accounting for kernfs nodes and iattrs Vasily Averin
2022-05-19 16:33 ` Michal Koutný
2022-05-20 1:12 ` Shakeel Butt
2022-05-13 15:52 ` [PATCH 3/4] memcg: enable accounting for struct cgroup Vasily Averin
2022-05-19 16:53 ` Michal Koutný
2022-05-20 7:24 ` Vasily Averin
2022-05-20 20:16 ` Vasily Averin
2022-05-21 0:55 ` Roman Gushchin
2022-05-21 7:28 ` Vasily Averin
2022-05-23 13:52 ` Michal Koutný
2022-05-20 1:31 ` Shakeel Butt
2022-05-13 15:52 ` [PATCH 4/4] memcg: enable accounting for allocations in alloc_fair_sched_group Vasily Averin
2022-05-19 16:45 ` Michal Koutný
2022-05-20 1:18 ` Shakeel Butt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c393a46-f6cf-ce8a-7771-81cbbc9ca278@openvz.org \
--to=vvs@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=kernel@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mkoutny@suse.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeelb@google.com \
--cc=songmuchun@bytedance.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).