linux/mm
Vlastimil Babka 9f821f9789 UPSTREAM: mm, slub: enable slub_debug static key when creating cache with explicit debug flags
Commit ca0cab65ea ("mm, slub: introduce static key for slub_debug()")
introduced a static key to optimize the case where no debugging is
enabled for any cache.  The static key is enabled when slub_debug boot
parameter is passed, or CONFIG_SLUB_DEBUG_ON enabled.

However, some caches might be created with one or more debugging flags
explicitly passed to kmem_cache_create(), and the commit missed this.
Thus the debugging functionality would not be actually performed for
these caches unless the static key gets enabled by boot param or config.

This patch fixes it by checking for debugging flags passed to
kmem_cache_create() and enabling the static key accordingly.

Note such explicit debugging flags should not be used outside of
debugging and testing as they will now enable the static key globally.
btrfs_init_cachep() creates a cache with SLAB_RED_ZONE but that's a
mistake that's being corrected [1].  rcu_torture_stats() creates a cache
with SLAB_STORE_USER, but that is a testing module so it's OK and will
start working as intended after this patch.

Also note that in case of backports to kernels before v5.12 that don't
have commit 59450bbc12 ("mm, slab, slub: stop taking cpu hotplug lock"),
static_branch_enable_cpuslocked() should be used.

[1] https://lore.kernel.org/linux-btrfs/20210315141824.26099-1-dsterba@suse.com/

Link: https://lkml.kernel.org/r/20210315153415.24404-1-vbabka@suse.cz
Fixes: ca0cab65ea ("mm, slub: introduce static key for slub_debug()")
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Oliver Glitta <glittao@gmail.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 1f0723a4c0)

Bug: 199581299
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: Ie075ba29e58a43fa96e7c177695d40103490c9ae
2021-09-16 11:41:47 +08:00
..
kasan BACKPORT: FROMLIST: kasan: add memzero int for unaligned size at DEBUG 2021-07-15 16:49:20 +00:00
kfence UPSTREAM: kfence: use TASK_IDLE when awaiting allocation 2021-08-27 12:26:09 -07:00
backing-dev.c
balloon_compaction.c
cleancache.c
cma_debug.c FROMLIST: mm: cma: introduce gfp flag in cma_alloc instead of no_warn 2021-01-25 12:21:02 -08:00
cma_sysfs.c ANDROID: make cma_sysfs experimental 2021-03-25 19:20:18 +00:00
cma.c ANDROID: mm: cma do not sleep for __GFP_NORETRY 2021-07-14 11:54:49 -07:00
cma.h ANDROID: GKI: add OEM data in cma struct 2021-06-04 11:15:16 -07:00
compaction.c UPSTREAM: mm/compaction: correct deferral logic for proactive compaction 2021-07-21 22:18:24 +00:00
debug_page_ref.c
debug_vm_pgtable.c mm/debug_vm_pgtable: fix alignment for pmd/pud_advanced_tests() 2021-06-10 13:39:26 +02:00
debug.c ANDROID: mm: introduce page_pinner 2021-04-30 09:13:34 -07:00
dmapool.c
early_ioremap.c
fadvise.c
failslab.c
filemap.c ANDROID: mm: unlock the page on speculative fault retry 2021-09-14 17:43:45 +00:00
frame_vector.c
frontswap.c
gup_benchmark.c
gup.c Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
highmem.c
hmm.c
huge_memory.c Merge 5.10.27 into android12-5.10 2021-04-02 15:25:50 +02:00
hugetlb_cgroup.c hugetlb_cgroup: fix imbalanced css_get and css_put pair for shared mappings 2021-03-30 14:31:54 +02:00
hugetlb.c Merge 5.10.43 into android12-5.10 2021-06-12 14:48:14 +02:00
hwpoison-inject.c
init-mm.c FROMLIST: mm: protect mm_rb tree with a rwlock 2021-01-22 18:00:57 +00:00
internal.h FROMLIST: mm: provide speculative fault infrastructure 2021-01-22 18:01:16 +00:00
interval_tree.c
ioremap.c
Kconfig FROMLIST: mm: cma: support sysfs 2021-03-25 19:20:09 +00:00
Kconfig.debug ANDROID: mm: introduce page_pinner 2021-04-30 09:13:34 -07:00
khugepaged.c Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
kmemleak.c UPSTREAM: kasan, kmemleak: reset tags when scanning block 2021-08-30 07:02:08 +00:00
ksm.c Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
list_lru.c
maccess.c
madvise.c FROMLIST: mm/madvise: add MADV_WILLNEED to process_madvise() 2021-08-16 15:13:13 +00:00
Makefile ANDROID: mm: introduce page_pinner 2021-04-30 09:13:34 -07:00
mapping_dirty_helpers.c
memblock.c UPSTREAM: mm: memblock: add more debug logs 2021-05-21 09:08:08 +05:30
memcontrol.c FROMLIST: mm, memcg: inline swap-related functions to improve disabled memcg config 2021-07-12 18:34:30 -07:00
memfd.c
memory_hotplug.c ANDROID: mm: cma: skip problematic pageblock 2021-07-14 11:54:49 -07:00
memory-failure.c mm/memory-failure: unnecessary amount of unmapping 2021-05-14 09:50:45 +02:00
memory.c UPSTREAM: mm: fix the deadlock in finish_fault() 2021-08-27 12:26:10 -07:00
mempolicy.c FROMLIST: mm: replace migrate_[prep|finish] with lru_cache_[disable|enable] 2021-03-23 04:05:24 +00:00
mempool.c FROMGIT: kasan: use separate (un)poison implementation for integrated init 2021-06-17 14:39:37 -07:00
memremap.c mm: fix memory_failure() handling of dax-namespace metadata 2021-03-04 11:38:21 +01:00
memtest.c
migrate.c Merge 5.10.38 into android12-5.10 2021-05-20 15:35:25 +02:00
mincore.c
mlock.c ANDROID: mm: page_pinner: unattribute follow_page in munlock_vma_pages_range 2021-04-30 09:13:35 -07:00
mm_init.c
mmap.c ANDROID: vendor_hooks: Add hook in mmap_region() 2021-09-06 16:51:38 +08:00
mmu_gather.c
mmu_notifier.c mm/mmu_notifiers: ensure range_end() is paired with range_start() 2021-03-30 14:32:06 +02:00
mmzone.c ANDROID: mm: export zone_watermark_ok 2021-02-25 19:36:38 +00:00
mprotect.c FROMGIT: mm: improve mprotect(R|W) efficiency on pages referenced once 2021-06-15 19:33:15 +00:00
mremap.c UPSTREAM: mm/mremap: hold the rmap lock in write mode when moving page table entries. 2021-07-15 18:39:14 +00:00
msync.c
nommu.c ANDROID: mm: allow vmas with vm_ops to be speculatively handled 2021-04-23 18:42:39 -07:00
oom_kill.c ANDROID: signal: Add vendor hook for memory reaping 2021-06-03 20:59:15 +00:00
page_alloc.c ANDROID: mm, kasan: fix for "integrate page_alloc init with HW_TAGS" 2021-07-20 00:38:20 +00:00
page_counter.c
page_ext.c ANDROID: mm: introduce page_pinner 2021-04-30 09:13:34 -07:00
page_idle.c
page_io.c UPSTREAM: mm/page_io: use pr_alert_ratelimited for swap read/write errors 2021-03-30 18:44:11 +00:00
page_isolation.c ANDROID: mm: cma: skip problematic pageblock 2021-07-14 11:54:49 -07:00
page_owner.c ANDROID: mm: Make page_owner_enabled global 2021-04-01 00:09:00 +00:00
page_pinner.c ANDROID: mm: page_pinner: use EXPORT_SYMBOL_GPL 2021-07-14 03:38:32 +00:00
page_poison.c UPSTREAM: kasan: fix conflict with page poisoning 2021-07-19 20:39:17 +00:00
page_reporting.c
page_reporting.h
page_vma_mapped.c
page-writeback.c ANDROID: vendor_hooks: add hook to balance_dirty_pages() 2021-05-20 19:38:42 +00:00
pagewalk.c
percpu-internal.h percpu: make pcpu_nr_empty_pop_pages per chunk type 2021-04-14 08:42:03 +02:00
percpu-km.c
percpu-stats.c percpu: make pcpu_nr_empty_pop_pages per chunk type 2021-04-14 08:42:03 +02:00
percpu-vm.c
percpu.c Merge 5.10.30 into android12-5.10 2021-04-15 14:23:41 +02:00
pgalloc-track.h
pgtable-generic.c
process_vm_access.c mm/process_vm_access.c: include compat.h 2021-01-19 18:27:21 +01:00
ptdump.c This is the 5.10.32 stable release 2021-04-22 11:12:08 +02:00
readahead.c
rmap.c ANDROID: vendor_hooks: Add hook in try_to_unmap_one() 2021-09-06 17:00:04 +08:00
rodata_test.c
shmem.c ANDROID: mm: provision to add shmem pages to inactive file lru head 2021-07-14 20:52:01 -07:00
shuffle.c
shuffle.h
slab_common.c ANDROID: vendor_hooks: Add hook in kmalloc_slab() 2021-09-03 00:17:50 +00:00
slab.c Merge 5.10.37 into android12-5.10 2021-05-15 09:28:55 +02:00
slab.h BACKPORT: FROMLIST: mm: move helper to check slub_debug_enabled 2021-07-15 16:49:09 +00:00
slob.c
slub.c UPSTREAM: mm, slub: enable slub_debug static key when creating cache with explicit debug flags 2021-09-16 11:41:47 +08:00
sparse-vmemmap.c
sparse.c mm/sparse: add the missing sparse_buffer_fini() in error branch 2021-05-14 09:50:45 +02:00
swap_cgroup.c
swap_slots.c
swap_state.c FROMLIST: mm: protect VMA modifications using VMA sequence count 2021-01-22 17:59:47 +00:00
swap.c ANDROID: mm: provision to add shmem pages to inactive file lru head 2021-07-14 20:52:01 -07:00
swapfile.c FROMLIST: mm, memcg: inline swap-related functions to improve disabled memcg config 2021-07-12 18:34:30 -07:00
truncate.c
usercopy.c
userfaultfd.c FROMGIT: userfaultfd/shmem: modify shmem_mfill_atomic_pte to use install_pte() 2021-06-04 19:13:10 +00:00
util.c ANDROID: android: export kernel function arch_mmap_rnd 2021-07-09 20:51:14 +00:00
vmacache.c
vmalloc.c ANDROID: GKI: Export two more mm symbols for GKI 2021-07-19 17:15:33 +00:00
vmpressure.c FROMLIST: mm, memcg: add mem_cgroup_disabled checks in vmpressure and swap-related functions 2021-07-12 18:26:15 -07:00
vmscan.c ANDROID: Allow vendor module to reclaim a memcg 2021-07-12 18:54:56 +00:00
vmstat.c ANDROID: mm: allow vmas with vm_ops to be speculatively handled 2021-04-23 18:42:39 -07:00
workingset.c
z3fold.c z3fold: prevent reclaim/free race for headless pages 2021-03-30 14:31:54 +02:00
zbud.c
zpool.c
zsmalloc.c This is the 5.10.21 stable release 2021-03-07 12:53:30 +01:00
zswap.c