Re: [PATCH v3 08/13] mm/slab: change struct slabobj_ext to a union
Hao Li <[email protected]> Thu, 30 Jul 2026 19:39:24 +0800
| Newsgroups | org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kvack.linux-mm |
|---|---|
| Message-ID | <ams30IqyBediM9kd@fedora> |
On Mon, Jul 27, 2026 at 02:54:02PM +0200, Vlastimil Babka (SUSE) wrote: > Currently, struct slabobj_ext can hold both objcg pointer and > codetag_ref (when both are compile-enabled) and there is an array of as > many slabobj_ext instances as there are objects in a slab. > > This makes the layout fixed so even if codetag_ref is unused (because > memory allocation profiling is disabled), the space for them is > allocated and wasted. Similarly, some caches (currently kmalloc_normal) > do not ever need objcg pointers, leading to wasted memory with memory > allocation profiling enabled. > > To make this more flexible, change the layout so that struct slabobj_ext > becomes a union of objcg pointer and codetag_ref (to ensure uniform > size; in practice both are the same size anyway). The slabobj_ext array > then can have twice as many elements as before. For cache locality > purposes, the effective memory layout is unchanged, so objcg and codetag > ref for a given object are still adjacent. > > cache_obj_ext_size() returns the effective size of (0-2) struct > slabobj_ext's for a cache, slab_obj_ext_size() for a slab. Currently > both return a constant value derived from the config options, but will > be made dynamic later. Replace all sizeof(slabobj_ext) usage with these. > > No functional change intended, the layout is still effectively static. > > Reviewed-by: Suren Baghdasaryan <[email protected]> > Signed-off-by: Vlastimil Babka (SUSE) <[email protected]> > --- LGTM. Reviewed-by: Hao Li <[email protected]> -- Thanks, Hao