Re: [PATCH] mm: memcg/slab: wait for !root kmem_cache refcnt killing on root kmem_cache destruction

From: Michal Hocko
Date: Thu Nov 28 2019 - 04:43:18 EST


On Wed 27-11-19 17:27:29, Roman Gushchin wrote:
> On Wed, Nov 27, 2019 at 01:32:25PM +0100, Michal Hocko wrote:
> > On Tue 26-11-19 18:41:41, Roman Gushchin wrote:
> > > On Tue, Nov 26, 2019 at 10:29:18AM +0100, Michal Hocko wrote:
> > > > On Mon 25-11-19 10:54:53, Roman Gushchin wrote:
> > [...]
> > > > > So in a rare case when not all children kmem_caches are destroyed
> > > > > at the moment when the root kmem_cache is about to be gone, we need
> > > > > to wait another rcu grace period before destroying the root
> > > > > kmem_cache.
> > > >
> > > > Could you explain how rare this really is please?
> > >
> > > It seems that we don't destroy root kmem_caches with enabled memcg
> > > accounting that often, but maybe I'm biased here.
> >
> > So this happens each time a root kmem_cache is destroyed? Which would
> > imply that only dynamically created ones?
>
> Yes, only dynamically created and only in those cases when destruction
> of the root cache happens immediately after the deactivation of the
> non-root cache.
> Tbh I can't imagine any other case except rmmod after
> removing the cgroup.

Thanks for the confirmation! Could you please make this explicit in the
changelog please? Maybe it is obvious to you but it took me quite some
time to grasp what the hell is going on here. Both memcg and kmem_cache
destruction are quite complex and convoluted.

Thanks a lot.

--
Michal Hocko
SUSE Labs