Re: [PATCH v2] mm: fix race between kmem_cache destroy, create and deactivate
From: Christopher Lameter
Date: Tue May 29 2018 - 09:59:13 EST
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.