On Fri, May 13, 2022 at 8:52 AM Vasily Averin <vvs@xxxxxxxxxx> wrote: > > 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. > > Accounting of this memory helps to avoid misuse inside memcg-limited > containers. > > Signed-off-by: Vasily Averin <vvs@xxxxxxxxxx> > --- > 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 adb820e98f24..7595127c5b3a 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); > Please include cgroup_rstat_cpu as well.