[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aWSUgKO4eGpodV1j@hyeyoo>
Date: Mon, 12 Jan 2026 15:28:16 +0900
From: Harry Yoo <harry.yoo@...cle.com>
To: Alexander Potapenko <glider@...gle.com>
Cc: akpm@...ux-foundation.org, vbabka@...e.cz, andreyknvl@...il.com,
cl@...two.org, dvyukov@...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, hao.li@...ux.dev, stable@...r.kernel.org
Subject: Re: [PATCH V5 1/8] mm/slab: use unsigned long for orig_size to
ensure proper metadata align
On Fri, Jan 09, 2026 at 10:30:47AM +0100, Alexander Potapenko wrote:
> > > Instead of calculating the offset of the original size in several
> > > places, should we maybe introduce a function that returns a pointer to
> > > it?
> >
> > Good point.
> >
> > The calculation of various metadata offset (including the original size)
> > is repeated in several places, and perhaps it's worth cleaning up,
> > something like this:
> >
> > enum {
> > FREE_POINTER_OFFSET,
> > ALLOC_TRACK_OFFSET,
> > FREE_TRACK_OFFSET,
> > ORIG_SIZE_OFFSET,
> > KASAN_ALLOC_META_OFFSET,
> > OBJ_EXT_OFFSET,
> > FINAL_ALIGNMENT_PADDING_OFFSET,
> > ...
> > };
> >
> > orig_size = *(unsigned long *)get_metadata_ptr(p, ORIG_SIZE_OFFSET);
>
> An alternative would be to declare a struct containing all the
> metadata fields and use offsetof() (or simply do a cast and access the
> fields via the struct pointer)
But considering that a cache may enable only a subset of those debugging
features, I'm not sure determining that offset for all caches at build
time is possible.
--
Cheers,
Harry / Hyeonggon
Powered by blists - more mailing lists