• Vasily Averin's avatar
    net: set proper memcg for net_init hooks allocations · 1d0403d2
    Vasily Averin authored
    __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.
    
    Link: https://lkml.kernel.org/r/f9394752-e272-9bf9-645f-a18c56d1c4ec@openvz.orgSigned-off-by: default avatarVasily Averin <vvs@openvz.org>
    Acked-by: default avatarRoman Gushchin <roman.gushchin@linux.dev>
    Acked-by: default avatarShakeel Butt <shakeelb@google.com>
    Cc: Michal Koutný <mkoutny@suse.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Florian Westphal <fw@strlen.de>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Paolo Abeni <pabeni@redhat.com>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
    Cc: Linux Kernel Functional Testing <lkft@linaro.org>
    Cc: Muchun Song <songmuchun@bytedance.com>
    Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
    Cc: Qian Cai <quic_qiancai@quicinc.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    1d0403d2
net_namespace.c 32.6 KB