Re: [PATCH v3 11/13] mm/slab: add cache_ and slab_needs_objcg() helpers

Harry Yoo <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm,gmane.linux.kernel.cgroups
Message-ID <anGjliizD1zRz60n@dev>
On Mon, Jul 27, 2026 at 02:54:05PM +0200, Vlastimil Babka (SUSE) wrote:
> Slabs of some caches never need the objcg part of struct slabobj_ext.
> Introduce helpers to query this for a cache or a slab.
> 
> Introduce SLAB_MAY_ACCOUNT flag that is currently only internal and all
> caches have it set except:
> 
> - KMALLOC_NORMAL caches, as long as KMALLOC_RECLAIM caches are separate
> - KMALLOC_NO_OBJ_EXT caches, if they exist
> 
> For named caches we currently can't derive SLAB_MAY_ACCOUNT from
> SLAB_ACCOUNT because some caches might be created without SLAB_ACCOUNT
> and then used both with and without __GFP_ACCOUNT concurrently,
> allocating obj_ext arrays on demand. So just add the SLAB_MAY_ACCOUNT
> to all kmem caches, unless kmem accounting is disabled.
> 
> This can be improved later by finding out all caches used with
> __GFP_ACCOUNT, creating them with the SLAB_MAY_ACCOUNT flag explicitly,
> and then ignoring __GFP_ACCOUNT for all other caches (possibly with a
> warning).
> 
> To make the evaluation of slab_needs_objcg() faster in the allocation
> and free fast paths, add a obj_exts_needs_objcg flag into slab itself.
> This optimization is only available on 64bit architectures where free
> bits are available for the flag.
> 
> Reviewed-by: Hao Li <[email protected]>
> Signed-off-by: Vlastimil Babka (SUSE) <[email protected]>
> ---

Reviewed-by: Harry Yoo <[email protected]>

-- 
Cheers,
Harry / Hyeonggon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.