[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALvZod5uw+f5dY=dUmHvdRq-4OfJBQ8zqjT5rZzpKtqQoy+28A@mail.gmail.com>
Date: Mon, 26 Apr 2021 12:39:44 -0700
From: Shakeel Butt <shakeelb@...gle.com>
To: Vasily Averin <vvs@...tuozzo.com>
Cc: Michal Hocko <mhocko@...e.com>, Cgroups <cgroups@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Roman Gushchin <guro@...com>,
Christian Brauner <christian.brauner@...ntu.com>,
Michal Koutný <mkoutny@...e.com>,
Serge Hallyn <serge@...lyn.com>
Subject: Re: [PATCH v2 1/1] memcg: enable accounting for pids in nested pid namespaces
On Sat, Apr 24, 2021 at 4:54 AM Vasily Averin <vvs@...tuozzo.com> wrote:
>
> Commit 5d097056c9a0 ("kmemcg: account certain kmem allocations to memcg")
> enabled memcg accounting for pids allocated from init_pid_ns.pid_cachep,
> but forgot to adjust the setting for nested pid namespaces.
> As a result, pid memory is not accounted exactly where it is really needed,
> inside memcg-limited containers with their own pid namespaces.
>
> Pid was one the first kernel objects enabled for memcg accounting.
> init_pid_ns.pid_cachep marked by SLAB_ACCOUNT and we can expect that
> any new pids in the system are memcg-accounted.
>
> Though recently I've noticed that it is wrong. nested pid namespaces creates
> own slab caches for pid objects, nested pids have increased size because contain
> id both for all parent and for own pid namespaces. The problem is that these slab
> caches are _NOT_ marked by SLAB_ACCOUNT, as a result any pids allocated in
> nested pid namespaces are not memcg-accounted.
>
> Pid struct in nested pid namespace consumes up to 500 bytes memory,
> 100000 such objects gives us up to ~50Mb unaccounted memory,
> this allow container to exceed assigned memcg limits.
>
> Fixes: 5d097056c9a0 ("kmemcg: account certain kmem allocations to memcg")
> Cc: stable@...r.kernel.org
> Signed-off-by: Vasily Averin <vvs@...tuozzo.com>
> Reviewed-by: Michal Koutný <mkoutny@...e.com>
> Acked-by: Christian Brauner <christian.brauner@...ntu.com>
> Acked-by: Roman Gushchin <guro@...com>
Reviewed-by: Shakeel Butt <shakeelb@...gle.com>
Powered by blists - more mailing lists