On Sat, 26 May 2018, Vladimir Davydov wrote: > > The reference counting is only implemented for root kmem_caches for > > simplicity. The reference of a root kmem_cache is elevated on sharing or > > while its memcg kmem_cache creation or deactivation request is in the > > fly and thus it is made sure that the root kmem_cache is not destroyed > > in the middle. As the reference of kmem_cache is elevated on sharing, > > the 'shared_count' does not need any locking protection as at worst it > > can be out-dated for a small window which is tolerable. > > I wonder if we could fix this problem without introducing reference > counting for kmem caches (which seems a bit of an overkill to me TBO), > e.g. by flushing memcg_kmem_cache_wq before root cache destruction? Would prefer that too but the whole memcg handling is something of a mystery to me.