Re: [PATCH v3 13/13] mm/slab, kfence, memcg: completely remove obj_ext for kfence objects

Hao Li <[email protected]> Thu, 30 Jul 2026 20:41:14 +0800
Newsgroups org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm
Message-ID <amtGQIpVU4WoWiXf@fedora>
On Mon, Jul 27, 2026 at 02:54:07PM +0200, Vlastimil Babka (SUSE) wrote:
> We have already disabled memory allocation profiling for objects
> allocated for KFENCE to avoid complexity. KFENCE allocations are rare
> and there can be only CONFIG_KFENCE_NUM_OBJECTS (default to 255)
> outstanding ones at any time, so they are among noise in the profiling
> stats.
> 
> For the same reasons, we can stop memcg_kmem accounting of kfence
> objects as their memory usage will be negligible wrt any practical
> memcg limits.
> 
> This allows us simplifying the code and getting rid of
> is_kfence_address() checks in various places, including slab_obj_ext()'s
> usage of obj_to_index(). Instead we rely on the fact that slab_obj_exts()
> will now always return 0 for a kfence object's fake slab, which makes
> those places unreachable.
> 
> All we need to do to keep this assumption valid is not to allocate
> obj_exts for kfence objects, so the checks need to guard
> alloc_slab_obj_exts() where necessary.
> 
> Suggested-by: Harry Yoo <[email protected]>
> Signed-off-by: Vlastimil Babka (SUSE) <[email protected]>

LGTM.
Reviewed-by: Hao Li <[email protected]>

-- 
Thanks,
Hao