linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Harry Yoo <harry.yoo@oracle.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	Christoph Lameter <cl@gentwo.org>,
	David Rientjes <rientjes@google.com>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Michal Hocko <mhocko@kernel.org>,
	Yeoreum Yun <yeoreum.yun@arm.com>,
	Suren Baghdasaryan <surenb@google.com>, Hai Li <hao.li@linux.dev>,
	linux-mm@kvack.org
Subject: To enable, or not to enable slab merging? That is the question (was: Re: [PATCH V1 0/2] Only allow SLAB_OBJ_EXT_IN_OBJ for unmergeable caches)
Date: Wed, 28 Jan 2026 12:09:10 +0900	[thread overview]
Message-ID: <aXl91hMQrkEcbwry@hyeyoo> (raw)
In-Reply-To: <aXkCFYWvbpZB_5oZ@cmpxchg.org>

On Tue, Jan 27, 2026 at 01:21:09PM -0500, Johannes Weiner wrote:
> On Tue, Jan 27, 2026 at 07:31:49PM +0900, Harry Yoo wrote:
> > While SLAB_OBJ_EXT_IN_OBJ allows to reduce memory overhead to account
> > slab objects, it prevents slab merging because merging can change
> > the metadata layout.
> >
> > As pointed out Vlastimil Babka, disabling merging solely for this memory
> > optimization may not be a net win, because disabling slab merging tends
> > to increase overall memory usage.

Hi Joahnnes,

> Is this motivated by a production issue or a more a correctness thing?

It's more of a correctness thing :)

> It's somewhat tangential, but we've had practical problems with slab
> merging and ended up disabling it in the Meta fleet. It makes it
> difficult to identify culprits when there is a footprint regression in
> merged caches.

Oh, yeah. slab merging makes it harder to investigate which caches are
actually contributing to the regression.

> IIRC there was at least one instance where it merged
> wildly different lifetimes, which raises fragmentation concerns.

That is a valid concern indeed.

> In the end we turned it off and noted no meaningful usage difference.

That's very interesting observation, I was thinking slab merging should
have some benefit in saving memory...

> So I'm curious if there are cases where it tangibly helps. And I
> wonder whether default y makes sense given its observability and
> predictability implications.

/me digs some old email threads

Julian Pidancet tried to change the default behavior a few years ago.
v2: https://lore.kernel.org/linux-mm/20230629221910.359711-1-julian.pidancet@oracle.com
v1: https://lore.kernel.org/linux-mm/20230627132131.214475-1-julian.pidancet@oracle.com

Christoph Lameter at that time had a concern about its impact on systems
with larger pages.
https://lore.kernel.org/linux-mm/2df9debe-cbdc-abf7-4db1-1628b29df801@os.amperecomputing.com

David Rientjes measured the difference between enabling vs. disabling
slab merging in memory usage / performance on some benchmarks.
https://lore.kernel.org/linux-mm/3bcfa538-4474-09b7-1812-b4260b09256a@google.com

The observation was that SReclaimable was only slightly increased
(which probably isn't a big deal as it's reclaimable), but there were some
performance regressions when disabling slab merging, most notably a -18%
will-it-scale.context_switch1_per_thread_ops regression on skylake
(but not on cascade lake, presumably due to differences in μarch).

Looks like at that time it was concluded that disabling slab merging
by default probably wasn't a clear-cut decision, given that it showed
a measurable regression on benchmarks and without knowing which
real-world workloads would be affected by corner cases.

-- 
Cheers,
Harry / Hyeonggon


      reply	other threads:[~2026-01-28  3:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 10:31 [PATCH V1 0/2] Only allow SLAB_OBJ_EXT_IN_OBJ for unmergeable caches Harry Yoo
2026-01-27 10:31 ` [PATCH V1 1/2] mm/slab: factor out slab_args_unmergeable() Harry Yoo
2026-01-27 16:35   ` Vlastimil Babka
2026-01-27 16:42     ` Harry Yoo
2026-01-27 16:49       ` Vlastimil Babka
2026-01-27 10:31 ` [PATCH V1 2/2] mm/slab: only allow SLAB_OBJ_EXT_IN_OBJ for unmergeable caches Harry Yoo
2026-02-03 11:56   ` Hao Li
2026-02-03 12:32     ` Harry Yoo
2026-02-04  0:45       ` Hao Li
2026-02-05  5:13         ` Harry Yoo
2026-02-05  6:27           ` Hao Li
2026-01-27 17:06 ` [PATCH V1 0/2] Only " Vlastimil Babka
2026-01-27 18:21 ` Johannes Weiner
2026-01-28  3:09   ` Harry Yoo [this message]

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=aXl91hMQrkEcbwry@hyeyoo \
    --to=harry.yoo@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=hannes@cmpxchg.org \
    --cc=hao.li@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=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=yeoreum.yun@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