[PATCH v2 0/6] mm/slab: Support selecting slab hardening features at boot
From: Chris Down
Date: Thu Oct 29 2026 - 02:07:18 EST
Slab hardening settings are currently all build time choices. This means
that, unfortunately, hosts with different requirements end up needing
separate kernel images. At Meta, for example, some hosts are built with
these options and the rest of the fleet isn't, and that's one of the
things that keeps those kernels apart.
Following the discussion on v1, this series now does two things:
- SLAB_FREELIST_HARDENED and SLAB_FREELIST_RANDOM are cheap enough with
sheaves that it makes more sense to just enable them by default than
to make them switchable. With both on, system level benchmarks didn't
change measurably, only slowpath heavy microbenchmarks did [1].
- SLAB_BUCKETS and KMALLOC_PARTITION_CACHES cost memory (Harry measured
about 1 MiB and 18 MiB respectively after boot on a 64 CPU VM [2]), so
they get slab_buckets= and kmalloc_partition= boot parameters, which
default to on when the option is built in.
Changes in v2:
- Make SLAB_FREELIST_HARDENED and SLAB_FREELIST_RANDOM default y instead
of adding boot parameters for them (Vlastimil).
- Skip the memdup_user() part of the slab_buckets test on !MMU
(Sashiko).
- Keep slab_buckets= and kmalloc_partition= separate for now. We can
discuss whether to merge them into slab_hardening= or similar, as
Harry suggested.
v1: https://lore.kernel.org/r/cover.1793086056.git.chris@xxxxxxxxxxxxxx
[1] https://lore.kernel.org/r/auITixAJMfLtfa7i@xxxxxxxxxxxxxx
[2] https://lore.kernel.org/r/179312451613.474906.1475329637924619088@xxxxxxxxxx
Chris Down (6):
mm/slab: Enable SLAB_FREELIST_HARDENED by default
mm/slab: Enable SLAB_FREELIST_RANDOM by default
mm/slab: Support disabling SLAB_BUCKETS at boot
slub_kunit: Add a test for the slab_buckets boot parameter
mm/slab: Support disabling KMALLOC_PARTITION_CACHES at boot
slub_kunit: Add a test for the kmalloc_partition boot parameter
.../admin-guide/kernel-parameters.txt | 15 ++++
lib/tests/slub_kunit.c | 87 +++++++++++++++++++
mm/Kconfig | 11 +++
mm/slab.h | 8 ++
mm/slab_common.c | 48 ++++++++--
5 files changed, 163 insertions(+), 6 deletions(-)
base-commit: d15d7703166daf7bd62c844a3cb1b3a6279adb4c
--
2.54.0