Messages in this thread | | | From | Shakeel Butt <> | Date | Tue, 26 Apr 2022 22:23:32 -0700 | Subject | Re: [PATCH memcg v4] net: set proper memcg for net_init hooks allocations |
| |
On Mon, Apr 25, 2022 at 11:43 PM Vasily Averin <vvs@openvz.org> wrote: > > __register_pernet_operations() executes init hook of registered > pernet_operation structure in all existing net namespaces. > > Typically, these hooks are called by a process associated with > the specified net namespace, and all __GFP_ACCOUNT marked > allocation are accounted for corresponding container/memcg. > > However __register_pernet_operations() calls the hooks in the same > context, and as a result all marked allocations are accounted > to one memcg for all processed net namespaces. > > This patch adjusts active memcg for each net namespace and helps > to account memory allocated inside ops_init() into the proper memcg. > > Signed-off-by: Vasily Averin <vvs@openvz.org>
Acked-by: Shakeel Butt <shakeelb@google.com>
[...] > > +static inline struct mem_cgroup *get_mem_cgroup_from_obj(void *p) > +{ > + struct mem_cgroup *memcg; > +
Do we need memcg_kmem_enabled() check here or maybe mem_cgroup_from_obj() should be doing memcg_kmem_enabled() instead of mem_cgroup_disabled() as we can have "cgroup.memory=nokmem" boot param.
> + rcu_read_lock(); > + do { > + memcg = mem_cgroup_from_obj(p); > + } while (memcg && !css_tryget(&memcg->css)); > + rcu_read_unlock(); > + return memcg; > +}
| |