From: Chris Down <chris@chrisdown.name>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Cc: Harry Yoo <harry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hao Li <hao.li@linux.dev>, Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Kees Cook <kees@kernel.org>, Marco Elver <elver@google.com>,
GONG Ruiqi <gongruiqi@huaweicloud.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Kieran Bingham <kbingham@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
linux-mm@kvack.org, linux-hardening@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH 0/8] mm/slab: Support selecting slab hardening features at boot
Date: Wed, 28 Oct 2026 23:23:55 +0800 [thread overview]
Message-ID: <auITixAJMfLtfa7i@chrisdown.name> (raw)
In-Reply-To: <16121542-acd5-4727-b64c-f8d519145b63@kernel.org>
Hi Vlastimil,
Vlastimil Babka (SUSE) writes:
>These two should be only a small cpu overhead, which is why distros
>generally enable them [1]. Also the code basically only runs in slowpaths
>because percpu caching doesn't use freelists. It's possible the static key
>conversion doesn't help anything. You could try to measure the impact, I'd
>be surprised perhaps :)
Well I measured it, and you're right :-)
I built kernels from d15d7703166d ("mm/slub: initialize the free pointer of the
bootstrap kmem_cache_node") toggling SLAB_FREELIST_HARDENED and
SLAB_FREELIST_RANDOM, with SLAB_BUCKETS, KMALLOC_PARTITION_CACHES and
SHUFFLE_PAGE_ALLOCATOR pinned off on an AMD Genoa.
With both on vs both off, sched messaging, perf bench syscall fork, a
tinyconfig kernel build and netperf over lo all moved by less than 0.8%, which
is within the noise here. So the slowpaths do pay, as you'd expect. Here's the
change in ns/object vs both off, over 64, 256 and 1024 byte objects:
hard rand both
batch alloc +5.5..+7.8% +7.6..+12.5% +13..+15%
bulk alloc -2.0..+3.9% +28..+32% +33..+38%
batch/bulk free +0.5..+4.6% -1.7..+0.6% +0.8..+4.5%
These are from a small module which just does ktime_get_ns() on one pinned CPU.
batch allocates 4096 objects with kmalloc() and then frees them 1000 times.
bulk does the same with kmem_cache_alloc_bulk() and kmem_cache_free_bulk() on a
private cache, so it keeps creating new slabs, which is where the random seq
gets applied.
So for us the right answer is to likely just turn these two on rather than make
them switchable, too.
>Maybe we should just make them default=y.
Agreed. In v2 I'll replace the boot parameters for these two with patches which
make them default y, and keep slab_buckets= and kmalloc_partition=.
Thank you for spotting this!
next prev parent reply other threads:[~2026-10-28 15:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 7:35 Chris Down
2026-10-27 7:35 ` [PATCH 1/8] mm/slub: Support disabling freelist hardening " Chris Down
2026-10-27 7:35 ` [PATCH 2/8] slub_kunit: Add a test for slab_freelist_hardened= Chris Down
2026-10-27 7:35 ` [PATCH 3/8] mm/slub: Support disabling freelist randomisation at boot Chris Down
2026-10-27 7:35 ` [PATCH 4/8] slub_kunit: Add a test for slab_freelist_random= Chris Down
2026-10-27 7:35 ` [PATCH 5/8] mm/slab: Support disabling SLAB_BUCKETS at boot Chris Down
2026-10-27 7:36 ` [PATCH 6/8] slub_kunit: Add a test for the slab_buckets boot parameter Chris Down
2026-10-27 7:36 ` [PATCH 7/8] mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot Chris Down
2026-10-27 7:36 ` [PATCH 8/8] slub_kunit: Add a test for the kmalloc_partition boot parameter Chris Down
2026-10-27 8:10 ` [PATCH 0/8] mm/slab: Support selecting slab hardening features at boot Vlastimil Babka (SUSE)
2026-10-27 18:31 ` Harry Yoo
2026-10-28 15:23 ` Chris Down [this message]
2026-10-28 15:06 ` Harry Yoo
2026-10-28 15:27 ` Chris Down
2026-10-28 15:37 ` 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=auITixAJMfLtfa7i@chrisdown.name \
--to=chris@chrisdown.name \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=corbet@lwn.net \
--cc=elver@google.com \
--cc=gongruiqi@huaweicloud.com \
--cc=hao.li@linux.dev \
--cc=harry@kernel.org \
--cc=jan.kiszka@siemens.com \
--cc=kbingham@kernel.org \
--cc=kees@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@kernel.org \
/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
all inboxes | Powered by JetHome®