From: Vlastimil Babka <vbabka@suse.cz>
To: Harry Yoo <harry.yoo@oracle.com>,
"Christoph Lameter (Ampere)" <cl@gentwo.org>
Cc: David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Suren Baghdasaryan <surenb@google.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
linux-mm@kvack.org
Subject: Re: [RFC PATCH] mm/slab: save memory by allocating slabobj_ext array from leftover
Date: Thu, 19 Jun 2025 09:56:59 +0200 [thread overview]
Message-ID: <bdf0af50-2e1d-4627-9775-ae62e2dee509@suse.cz> (raw)
In-Reply-To: <aExkJhM_P8mnLC12@hyeyoo>
On 6/13/25 19:47, Harry Yoo wrote:
> On Fri, Jun 13, 2025 at 09:04:34AM -0700, Christoph Lameter (Ampere) wrote:
>> On Fri, 13 Jun 2025, Harry Yoo wrote:
>>
>> > Allocate slabobj_exts array from this unused space instead of using
>> > kcalloc(), when it is large enough.
>>
>> How does slab debug work in this case? The object layout gets a bit
>> complicated with other metadata there as well.
>
> Oh, the 'leftover' space I mentioned the cover letter refers to the
> wasted space after the last object in a slab, not unused bytes within
> objects.
>
> There is no per-object metadata stored there and SLUB simply poisons the area.
> I taught slab_pad_check() to skip checking the slabobj_exts array.
I can imagine going further with this in case where leftover space in slab
isn't enough.
- indeed use per-object padding to store only single object's slabobj_ext,
if it doesn't lead to memory waste
- if not possible, but object size is small enough so there are many per
slab, maybe have one less object per slab to store the array?
- once we have struct slab decoupled from struct page, it could be part of
struct slab directly (but it would mean struct slab isn't fixed size)
Of course having multiple variants would risk slower code, so fast paths
should not be affected - we could have pointer to the 0th slabobj_ext (we
already have) and now also stride (to support the "per-object padding case"
- there's still space in struct slab right?) and then the object alloc/free
case could be oblivious to the storage method, with just a bit more
arithmetic (stride). Slab folio alloc/free would be more complicated but are
not fath path.
Also some variants would be wasteful if they need to be decided upfront (the
2nd and 3rd above) and then the array is unused, so would be only applicable
with SLAB_ACCOUNT caches (if kmemcg is active) or when memalloc profiling is
active. Shouldn't be a big issue as ad-hoc __GFP_ACCOUNT is handled by
different cache selection for kmalloc() and I don't know if anyone is
actually doing ad-hoc __GFP_ACCOUNT on named caches.
next prev parent reply other threads:[~2025-06-19 7:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 6:33 Harry Yoo
2025-06-13 7:11 ` Harry Yoo
2025-06-13 11:42 ` Yeoreum Yun
2025-06-13 17:58 ` Harry Yoo
2025-06-13 16:04 ` Christoph Lameter (Ampere)
2025-06-13 17:47 ` Harry Yoo
2025-06-16 11:00 ` Harry Yoo
2025-06-19 7:56 ` Vlastimil Babka [this message]
2025-08-05 11:57 ` Harry Yoo
2025-08-08 14:44 ` Vlastimil Babka
2025-08-27 11:40 ` Harry Yoo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bdf0af50-2e1d-4627-9775-ae62e2dee509@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=cl@gentwo.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=ryabinin.a.a@gmail.com \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vincenzo.frascino@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox