[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aV9bFEuaMoXIjTkP@hyeyoo>
Date: Thu, 8 Jan 2026 16:21:56 +0900
From: Harry Yoo <harry.yoo@...cle.com>
To: Hao Li <hao.li@...ux.dev>
Cc: akpm@...ux-foundation.org, vbabka@...e.cz, andreyknvl@...il.com,
cl@...two.org, dvyukov@...gle.com, glider@...gle.com,
hannes@...xchg.org, linux-mm@...ck.org, mhocko@...nel.org,
muchun.song@...ux.dev, rientjes@...gle.com, roman.gushchin@...ux.dev,
ryabinin.a.a@...il.com, shakeel.butt@...ux.dev, surenb@...gle.com,
vincenzo.frascino@....com, yeoreum.yun@....com, tytso@....edu,
adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org, cgroups@...r.kernel.org
Subject: Re: [PATCH V5 4/8] mm/slab: abstract slabobj_ext access via new
slab_obj_ext() helper
On Wed, Jan 07, 2026 at 10:53:48PM +0800, Hao Li wrote:
> On Mon, Jan 05, 2026 at 05:02:26PM +0900, Harry Yoo wrote:
> > Currently, the slab allocator assumes that slab->obj_exts is a pointer
> > to an array of struct slabobj_ext objects. However, to support storage
> > methods where struct slabobj_ext is embedded within objects, the slab
> > allocator should not make this assumption. Instead of directly
> > dereferencing the slabobj_exts array, abstract access to
> > struct slabobj_ext via helper functions.
> >
> > Introduce a new API slabobj_ext metadata access:
> >
> > slab_obj_ext(slab, obj_exts, index) - returns the pointer to
> > struct slabobj_ext element at the given index.
> >
> > Directly dereferencing the return value of slab_obj_exts() is no longer
> > allowed. Instead, slab_obj_ext() must always be used to access
> > individual struct slabobj_ext objects.
> >
> > Convert all users to use these APIs.
> > No functional changes intended.
> >
> > Signed-off-by: Harry Yoo <harry.yoo@...cle.com>
> > ---
> > mm/memcontrol.c | 23 +++++++++++++++-------
> > mm/slab.h | 43 +++++++++++++++++++++++++++++++++++------
> > mm/slub.c | 51 ++++++++++++++++++++++++++++---------------------
> > 3 files changed, 82 insertions(+), 35 deletions(-)
> >
> > diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> > index be810c1fbfc3..fd9105a953b0 100644
> > --- a/mm/memcontrol.c
> > +++ b/mm/memcontrol.c
> > @@ -533,7 +558,13 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,
> >
> > #else /* CONFIG_SLAB_OBJ_EXT */
> >
> > -static inline struct slabobj_ext *slab_obj_exts(struct slab *slab)
> > +static inline unsigned long slab_obj_exts(struct slab *slab)
> > +{
> > + return 0;
> > +}
> > +
> > +static inline struct slabobj_ext *slab_obj_ext(struct slab *slab,
> > + unsigned int index)
>
> Hi Harry,
Hi Hao, thank you so much for reviewing it!
> just a small nit: the parameter list of slab_obj_ext() should
> include `unsigned long obj_exts`.
Ouch, made a silly mistake.
You're right.
Interestingly it didn't break CONFIG_SLAB_OBJ_EXT=n builds perhaps
because it was unreachable as Vlastimil mentioned it elsewhere.
I'll fix it anyway in the next version.
--
Cheers,
Harry / Hyeonggon
Powered by blists - more mailing lists