I had view the slab kmem_cache_alloc function,I think the virtual netdevice object will charged to memcg.
Becuse the function slab_pre_alloc_hook will choose a kmem_cache, which belong to current task memcg.
If  virtual netdevice object not destroy by another command, the virtual netdevice object will still charged to memcg, and the memcg will still in memory.

Above is just an example.
The general scenario is as follows
if a user process which has own memcg creates a semi-permeanent kernel object , and does not release this kernel object before exit.
The memcg which belong to this process will just offline but not release until the semi-permeanent kernel object release.

I think in those case, kernel will hold more memory than user’s think。no just sizeof(struct blabla),but sizeof(struct blabla) + memory memcg used.

bytedance.net
段熊春
duanxiongchun@bytedance.com




On Nov 22, 2018, at 12:27 AM, Michal Hocko <mhocko@kernel.org> wrote:

On Wed 21-11-18 17:36:51, 段熊春 wrote:
hi all:

In same case, I think it’s may be a problem。

if I create a virtual netdev device under mem cgroup(like ip link add ve_A type veth peer name ve_B).after that ,I destroy this mem cgroup。

Which object is charged to that memcg? If there is no relation to any
task context then accounting to a memcg is problematic.

--
Michal Hocko
SUSE Labs