Re: [PATCH RFC 08/12] mm/slab: change struct slabobj_ext to a union
From: Suren Baghdasaryan
Date: Thu Jul 16 2026 - 11:29:15 EST
On Thu, Jul 16, 2026 at 7:43 AM Vlastimil Babka (SUSE)
<vbabka@xxxxxxxxxx> wrote:
>
> On 7/16/26 06:11, Suren Baghdasaryan wrote:
> > On Wed, Jul 15, 2026 at 3:11 AM Vlastimil Babka (SUSE)
> > <vbabka@xxxxxxxxxx> wrote:
> >> No functional change intended, the layout is still effectively static.
> >>
> >> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> >
> > This is much cleaner than what I was preparing. Nicely done!
> >
> > Reviewed-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
>
> Thanks!
>
> >> ---
> >> mm/slab.h | 41 +++++++++++++++++++++++++++++++++--------
> >> mm/slub.c | 17 +++++++++--------
> >> 2 files changed, 42 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/mm/slab.h b/mm/slab.h
> >> index 3ad9777ad600..359ab8caf61e 100644
> >> --- a/mm/slab.h
> >> +++ b/mm/slab.h
> >> @@ -554,14 +554,34 @@ static inline bool need_kmalloc_no_objext(void)
> >> * if MEMCG_DATA_OBJEXTS is set.
> >> */
> >> struct slabobj_ext {
> >
> > Perhaps we should add a comment here stating that every element of
> > this union should be pointer-sized?
> >
>
> OK, how about this?
>
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -550,10 +550,14 @@ static inline bool need_kmalloc_no_objext(void)
> }
>
> /*
> - * Extended information for slab objects stored as an array in page->memcg_data
> - * if MEMCG_DATA_OBJEXTS is set.
> + * Extended information for slab objects stored as a pointer to an array in
> + * slab->obj_exts (aliasing page->memcg_data) if MEMCG_DATA_OBJEXTS is set.
> */
> struct slabobj_ext {
> + /*
> + * All elements of the union should be pointer-sized to avoid memory
> + * waste
> + */
Perfect. Thank you!
> union {
> #ifdef CONFIG_MEMCG
> struct obj_cgroup *_objcg;
>