Re: [PATCH V5 8/8] mm/slab: place slabobj_ext metadata in unused space within s->size
From: Harry Yoo
Date: Thu Jan 08 2026 - 07:41:51 EST
On Thu, Jan 08, 2026 at 01:52:09PM +0800, Hao Li wrote:
> On Mon, Jan 05, 2026 at 05:02:30PM +0900, Harry Yoo wrote:
> > When a cache has high s->align value and s->object_size is not aligned
> > to it, each object ends up with some unused space because of alignment.
> > If this wasted space is big enough, we can use it to store the
> > slabobj_ext metadata instead of wasting it.
>
> Hi, Harry,
Hi Hao,
> When we save obj_ext in s->size space, it seems that slab_ksize() might
> be missing the corresponding handling.
Oops.
> It still returns s->size, which could cause callers of slab_ksize()
> to see unexpected data (i.e. obj_ext), or even overwrite the obj_ext data.
Yes indeed.
Great point, thanks!
I'll fix it by checking if the slab has obj_exts within the object
layout and returning s->object_size if so.
--
Cheers,
Harry / Hyeonggon