On Thu, Dec 03, 2026 at 02:17:21PM +0000, Hao Li wrote:
> On Wed, Nov 25, 2026 at 09:37:15PM +0000, Harry Yoo (Meta) wrote:
> > Now that all caches whose objects may be allocated with __GFP_ACCOUNT > > specify SLAB_MAY_ACCOUNT (or SLAB_ACCOUNT, which implies it), stop > > assuming any cache may be used with __GFP_ACCOUNT. This avoids wasting > > the objcg slot in slabobj_ext for caches that are never charged to a > > memcg. > > > > Signed-off-by: Harry Yoo (Meta) <har…@kernel.org> > > --- > > diff --git a/mm/slab_common.c b/mm/slab_common.c > > index 193b5a03bc47..464695504248 100644 > > --- a/mm/slab_common.c > > +++ b/mm/slab_common.c > > @@ -367,12 +367,10 @@ struct kmem_cache *__kmem_cache_create_args(const char *name, > > goto out_unlock; > > } > > > > - /* > > - * For now we assume any cache can be used with __GFP_ACCOUNT and thus > > - * may need to store objcg pointers for objects > > - */ > > - if (!mem_cgroup_kmem_disabled()) > > + if (flags & SLAB_ACCOUNT) > > flags |= SLAB_MAY_ACCOUNT; > > + if (mem_cgroup_kmem_disabled()) > > + flags &= ~SLAB_MAY_ACCOUNT;
> > Btw, say maple_node/sk_buff/... could be merged with cacheX before. After this > patch, cacheX loses SLAB_MAY_ACCOUNT while we still set SLAB_MAY_ACCOUNT for > maple_node explicitly, so they can't be merged anymore. Not sure if it matters, > though.
Hmm you mean SLAB_ACCOUNT and SLAB_MAY_ACCOUNT should be cleared at run-time during merging decision with cgroup.memory=nokmem?
-- Cheers, Harry / Hyeonggon