Re: [PATCH v3 13/13] mm/slab, kfence, memcg: completely remove obj_ext for kfence objects
From: Hao Li
Date: Thu Jul 30 2026 - 08:45:32 EST
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 <harry@xxxxxxxxxx>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
LGTM.
Reviewed-by: Hao Li <hao.li@xxxxxxxxx>
--
Thanks,
Hao