mm/slab: remove CONFIG_SLAB from all Kconfig and Makefile
authorVlastimil Babka <vbabka@suse.cz>
Mon, 2 Oct 2023 13:43:03 +0000 (15:43 +0200)
committerVlastimil Babka <vbabka@suse.cz>
Tue, 5 Dec 2023 10:14:40 +0000 (11:14 +0100)
Remove CONFIG_SLAB, CONFIG_DEBUG_SLAB, CONFIG_SLAB_DEPRECATED and
everything in Kconfig files and mm/Makefile that depends on those. Since
SLUB is the only remaining allocator, remove the allocator choice, make
CONFIG_SLUB a "def_bool y" for now and remove all explicit dependencies
on SLUB or SLAB as it's now always enabled. Make every option's verbose
name and description refer to "the slab allocator" without refering to
the specific implementation. Do not rename the CONFIG_ option names yet.

Everything under #ifdef CONFIG_SLAB, and mm/slab.c is now dead code, all
code under #ifdef CONFIG_SLUB is now always compiled.

Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Christoph Lameter <cl@linux.com>
Acked-by: David Rientjes <rientjes@google.com>
Tested-by: David Rientjes <rientjes@google.com>
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
arch/arm64/Kconfig
arch/s390/Kconfig
arch/x86/Kconfig
lib/Kconfig.debug
lib/Kconfig.kasan
lib/Kconfig.kfence
lib/Kconfig.kmsan
mm/Kconfig
mm/Kconfig.debug
mm/Makefile

index 7b071a00425d2b833bc79dd0413bafaaeb94c19a..325b7140b576381390f75ee9c19715aff621a49f 100644 (file)
@@ -154,7 +154,7 @@ config ARM64
        select HAVE_MOVE_PUD
        select HAVE_PCI
        select HAVE_ACPI_APEI if (ACPI && EFI)
-       select HAVE_ALIGNED_STRUCT_PAGE if SLUB
+       select HAVE_ALIGNED_STRUCT_PAGE
        select HAVE_ARCH_AUDITSYSCALL
        select HAVE_ARCH_BITREVERSE
        select HAVE_ARCH_COMPILER_H
index 3bec98d20283b4eee33f946111ed35e3f8897bff..afa42a6f2e09a582362c4f5da65120fc7162e0d8 100644 (file)
@@ -146,7 +146,7 @@ config S390
        select GENERIC_TIME_VSYSCALL
        select GENERIC_VDSO_TIME_NS
        select GENERIC_IOREMAP if PCI
-       select HAVE_ALIGNED_STRUCT_PAGE if SLUB
+       select HAVE_ALIGNED_STRUCT_PAGE
        select HAVE_ARCH_AUDITSYSCALL
        select HAVE_ARCH_JUMP_LABEL
        select HAVE_ARCH_JUMP_LABEL_RELATIVE
index 3762f41bb092971e3f6180f057b49742014e5f11..3f460f334d4e29bc3223a9184ed4c812a809b2d7 100644 (file)
@@ -169,7 +169,7 @@ config X86
        select HAS_IOPORT
        select HAVE_ACPI_APEI                   if ACPI
        select HAVE_ACPI_APEI_NMI               if ACPI
-       select HAVE_ALIGNED_STRUCT_PAGE         if SLUB
+       select HAVE_ALIGNED_STRUCT_PAGE
        select HAVE_ARCH_AUDITSYSCALL
        select HAVE_ARCH_HUGE_VMAP              if X86_64 || X86_PAE
        select HAVE_ARCH_HUGE_VMALLOC           if X86_64
index cc7d53d9dc0191c544b0e2a71d0a6500b854924c..e1765face1068826b1191a975c5f0aeab9be9e8a 100644 (file)
@@ -1985,7 +1985,6 @@ config FAULT_INJECTION
 config FAILSLAB
        bool "Fault-injection capability for kmalloc"
        depends on FAULT_INJECTION
-       depends on SLAB || SLUB
        help
          Provide fault-injection capability for kmalloc.
 
index fdca89c057452e7715a21316a1d3b763a525d785..97e1fdbb59104440345c188269dc5353e370ea9e 100644 (file)
@@ -37,7 +37,7 @@ menuconfig KASAN
                     (HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS)) && \
                    CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \
                   HAVE_ARCH_KASAN_HW_TAGS
-       depends on (SLUB && SYSFS && !SLUB_TINY) || (SLAB && !DEBUG_SLAB)
+       depends on SYSFS && !SLUB_TINY
        select STACKDEPOT_ALWAYS_INIT
        help
          Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety
@@ -78,7 +78,7 @@ config KASAN_GENERIC
        bool "Generic KASAN"
        depends on HAVE_ARCH_KASAN && CC_HAS_KASAN_GENERIC
        depends on CC_HAS_WORKING_NOSANITIZE_ADDRESS
-       select SLUB_DEBUG if SLUB
+       select SLUB_DEBUG
        select CONSTRUCTORS
        help
          Enables Generic KASAN.
@@ -89,13 +89,11 @@ config KASAN_GENERIC
          overhead of ~50% for dynamic allocations.
          The performance slowdown is ~x3.
 
-         (Incompatible with CONFIG_DEBUG_SLAB: the kernel does not boot.)
-
 config KASAN_SW_TAGS
        bool "Software Tag-Based KASAN"
        depends on HAVE_ARCH_KASAN_SW_TAGS && CC_HAS_KASAN_SW_TAGS
        depends on CC_HAS_WORKING_NOSANITIZE_ADDRESS
-       select SLUB_DEBUG if SLUB
+       select SLUB_DEBUG
        select CONSTRUCTORS
        help
          Enables Software Tag-Based KASAN.
@@ -110,12 +108,9 @@ config KASAN_SW_TAGS
          May potentially introduce problems related to pointer casting and
          comparison, as it embeds a tag into the top byte of each pointer.
 
-         (Incompatible with CONFIG_DEBUG_SLAB: the kernel does not boot.)
-
 config KASAN_HW_TAGS
        bool "Hardware Tag-Based KASAN"
        depends on HAVE_ARCH_KASAN_HW_TAGS
-       depends on SLUB
        help
          Enables Hardware Tag-Based KASAN.
 
index 459dda9ef619b872f8bdca63131a311a7ca601bd..6fbbebec683ae5fe252b50d2870d7d2cc3407d01 100644 (file)
@@ -5,7 +5,7 @@ config HAVE_ARCH_KFENCE
 
 menuconfig KFENCE
        bool "KFENCE: low-overhead sampling-based memory safety error detector"
-       depends on HAVE_ARCH_KFENCE && (SLAB || SLUB)
+       depends on HAVE_ARCH_KFENCE
        select STACKTRACE
        select IRQ_WORK
        help
index ef2c8f256c57dac3c2575249c91382707cd63a83..0541d7b079cc110dcbafda979dfaf63675ac5eaa 100644 (file)
@@ -11,7 +11,7 @@ config HAVE_KMSAN_COMPILER
 config KMSAN
        bool "KMSAN: detector of uninitialized values use"
        depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER
-       depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN
+       depends on DEBUG_KERNEL && !KASAN && !KCSAN
        depends on !PREEMPT_RT
        select STACKDEPOT
        select STACKDEPOT_ALWAYS_INIT
index 89971a894b6058fd7b908c0e8ffa216cbdc887dd..4636870499bbeec73c72eb50724ee17367fe771d 100644 (file)
@@ -226,52 +226,17 @@ config ZSMALLOC_CHAIN_SIZE
 
          For more information, see zsmalloc documentation.
 
-menu "SLAB allocator options"
-
-choice
-       prompt "Choose SLAB allocator"
-       default SLUB
-       help
-          This option allows to select a slab allocator.
-
-config SLAB_DEPRECATED
-       bool "SLAB (DEPRECATED)"
-       depends on !PREEMPT_RT
-       help
-         Deprecated and scheduled for removal in a few cycles. Replaced by
-         SLUB.
-
-         If you cannot migrate to SLUB, please contact linux-mm@kvack.org
-         and the people listed in the SLAB ALLOCATOR section of MAINTAINERS
-         file, explaining why.
-
-         The regular slab allocator that is established and known to work
-         well in all environments. It organizes cache hot objects in
-         per cpu and per node queues.
+menu "Slab allocator options"
 
 config SLUB
-       bool "SLUB (Unqueued Allocator)"
-       help
-          SLUB is a slab allocator that minimizes cache line usage
-          instead of managing queues of cached objects (SLAB approach).
-          Per cpu caching is realized using slabs of objects instead
-          of queues of objects. SLUB can use memory efficiently
-          and has enhanced diagnostics. SLUB is the default choice for
-          a slab allocator.
-
-endchoice
-
-config SLAB
-       bool
-       default y
-       depends on SLAB_DEPRECATED
+       def_bool y
 
 config SLUB_TINY
-       bool "Configure SLUB for minimal memory footprint"
-       depends on SLUB && EXPERT
+       bool "Configure for minimal memory footprint"
+       depends on EXPERT
        select SLAB_MERGE_DEFAULT
        help
-          Configures the SLUB allocator in a way to achieve minimal memory
+          Configures the slab allocator in a way to achieve minimal memory
           footprint, sacrificing scalability, debugging and other features.
           This is intended only for the smallest system that had used the
           SLOB allocator and is not recommended for systems with more than
@@ -282,7 +247,6 @@ config SLUB_TINY
 config SLAB_MERGE_DEFAULT
        bool "Allow slab caches to be merged"
        default y
-       depends on SLAB || SLUB
        help
          For reduced kernel memory fragmentation, slab caches can be
          merged when they share the same size and other characteristics.
@@ -296,7 +260,7 @@ config SLAB_MERGE_DEFAULT
 
 config SLAB_FREELIST_RANDOM
        bool "Randomize slab freelist"
-       depends on SLAB || (SLUB && !SLUB_TINY)
+       depends on !SLUB_TINY
        help
          Randomizes the freelist order used on creating new pages. This
          security feature reduces the predictability of the kernel slab
@@ -304,21 +268,19 @@ config SLAB_FREELIST_RANDOM
 
 config SLAB_FREELIST_HARDENED
        bool "Harden slab freelist metadata"
-       depends on SLAB || (SLUB && !SLUB_TINY)
+       depends on !SLUB_TINY
        help
          Many kernel heap attacks try to target slab cache metadata and
          other infrastructure. This options makes minor performance
          sacrifices to harden the kernel slab allocator against common
-         freelist exploit methods. Some slab implementations have more
-         sanity-checking than others. This option is most effective with
-         CONFIG_SLUB.
+         freelist exploit methods.
 
 config SLUB_STATS
        default n
-       bool "Enable SLUB performance statistics"
-       depends on SLUB && SYSFS && !SLUB_TINY
+       bool "Enable performance statistics"
+       depends on SYSFS && !SLUB_TINY
        help
-         SLUB statistics are useful to debug SLUBs allocation behavior in
+         The statistics are useful to debug slab allocation behavior in
          order find ways to optimize the allocator. This should never be
          enabled for production use since keeping statistics slows down
          the allocator by a few percentage points. The slabinfo command
@@ -328,8 +290,8 @@ config SLUB_STATS
 
 config SLUB_CPU_PARTIAL
        default y
-       depends on SLUB && SMP && !SLUB_TINY
-       bool "SLUB per cpu partial cache"
+       depends on SMP && !SLUB_TINY
+       bool "Enable per cpu partial caches"
        help
          Per cpu partial caches accelerate objects allocation and freeing
          that is local to a processor at the price of more indeterminism
@@ -339,7 +301,7 @@ config SLUB_CPU_PARTIAL
 
 config RANDOM_KMALLOC_CACHES
        default n
-       depends on SLUB && !SLUB_TINY
+       depends on !SLUB_TINY
        bool "Randomize slab caches for normal kmalloc"
        help
          A hardening feature that creates multiple copies of slab caches for
@@ -354,7 +316,7 @@ config RANDOM_KMALLOC_CACHES
          limited degree of memory and CPU overhead that relates to hardware and
          system workload.
 
-endmenu # SLAB allocator options
+endmenu # Slab allocator options
 
 config SHUFFLE_PAGE_ALLOCATOR
        bool "Page allocator randomization"
index 018a5bd2f576defbaabaff287d835e29b8222be5..321ab379994f693d972e513d996f7e66e31b8ada 100644 (file)
@@ -45,18 +45,10 @@ config DEBUG_PAGEALLOC_ENABLE_DEFAULT
          Enable debug page memory allocations by default? This value
          can be overridden by debug_pagealloc=off|on.
 
-config DEBUG_SLAB
-       bool "Debug slab memory allocations"
-       depends on DEBUG_KERNEL && SLAB
-       help
-         Say Y here to have the kernel do limited verification on memory
-         allocation as well as poisoning memory on free to catch use of freed
-         memory. This can make kmalloc/kfree-intensive workloads much slower.
-
 config SLUB_DEBUG
        default y
        bool "Enable SLUB debugging support" if EXPERT
-       depends on SLUB && SYSFS && !SLUB_TINY
+       depends on SYSFS && !SLUB_TINY
        select STACKDEPOT if STACKTRACE_SUPPORT
        help
          SLUB has extensive debug support features. Disabling these can
@@ -66,7 +58,7 @@ config SLUB_DEBUG
 
 config SLUB_DEBUG_ON
        bool "SLUB debugging on by default"
-       depends on SLUB && SLUB_DEBUG
+       depends on SLUB_DEBUG
        select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT
        default n
        help
@@ -231,8 +223,8 @@ config DEBUG_KMEMLEAK
          allocations. See Documentation/dev-tools/kmemleak.rst for more
          details.
 
-         Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
-         of finding leaks due to the slab objects poisoning.
+         Enabling SLUB_DEBUG may increase the chances of finding leaks
+         due to the slab objects poisoning.
 
          In order to access the kmemleak file, debugfs needs to be
          mounted (usually at /sys/kernel/debug).
index 33873c8aedb399b3e9b6eb610d4fef31a2e0f17e..e4b5b75aaec9c1192e3a60e922d90f0704155615 100644 (file)
@@ -4,7 +4,6 @@
 #
 
 KASAN_SANITIZE_slab_common.o := n
-KASAN_SANITIZE_slab.o := n
 KASAN_SANITIZE_slub.o := n
 KCSAN_SANITIZE_kmemleak.o := n
 
@@ -12,7 +11,6 @@ KCSAN_SANITIZE_kmemleak.o := n
 # the same word but accesses to different bits of that word. Re-enable KCSAN
 # for these when we have more consensus on what to do about them.
 KCSAN_SANITIZE_slab_common.o := n
-KCSAN_SANITIZE_slab.o := n
 KCSAN_SANITIZE_slub.o := n
 KCSAN_SANITIZE_page_alloc.o := n
 # But enable explicit instrumentation for memory barriers.
@@ -22,7 +20,6 @@ KCSAN_INSTRUMENT_BARRIERS := y
 # flaky coverage that is not a function of syscall inputs. E.g. slab is out of
 # free pages, or a task is migrated between nodes.
 KCOV_INSTRUMENT_slab_common.o := n
-KCOV_INSTRUMENT_slab.o := n
 KCOV_INSTRUMENT_slub.o := n
 KCOV_INSTRUMENT_page_alloc.o := n
 KCOV_INSTRUMENT_debug-pagealloc.o := n
@@ -66,6 +63,7 @@ obj-y += page-alloc.o
 obj-y += init-mm.o
 obj-y += memblock.o
 obj-y += $(memory-hotplug-y)
+obj-y += slub.o
 
 ifdef CONFIG_MMU
        obj-$(CONFIG_ADVISE_SYSCALLS)   += madvise.o
@@ -82,8 +80,6 @@ obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
 obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
 obj-$(CONFIG_KSM) += ksm.o
 obj-$(CONFIG_PAGE_POISONING) += page_poison.o
-obj-$(CONFIG_SLAB) += slab.o
-obj-$(CONFIG_SLUB) += slub.o
 obj-$(CONFIG_KASAN)    += kasan/
 obj-$(CONFIG_KFENCE) += kfence/
 obj-$(CONFIG_KMSAN)    += kmsan/