// SPDX-License-Identifier: GPL-2.0/* * Slab allocator functions that are independent of the allocator strategy * * (C) 2012 Christoph Lameter <cl@linux.com> */#include<linux/slab.h>#include<linux/mm.h>#include<linux/poison.h>#include<linux/interrupt.h>#include<linux/memory.h>#include<linux/cache.h>#include<linux/compiler.h>#include<linux/kfence.h>#include<linux/module.h>#include<linux/cpu.h>#include<linux/uaccess.h>#include<linux/seq_file.h>#include<linux/dma-mapping.h>#include<linux/swiotlb.h>#include<linux/proc_fs.h>#include<linux/debugfs.h>#include<linux/kmemleak.h>#include<linux/kasan.h>#include<asm/cacheflush.h>#include<asm/tlbflush.h>#include<asm/page.h>#include<linux/memcontrol.h>#include<linux/stackdepot.h>#include"internal.h"#include"slab.h"#define CREATE_TRACE_POINTS#include<trace/events/kmem.h>enumslab_stateslab_state;LIST_HEAD(slab_caches);DEFINE_MUTEX(slab_mutex);structkmem_cache*kmem_cache;staticLIST_HEAD(slab_caches_to_rcu_destroy);staticvoidslab_caches_to_rcu_destroy_workfn(structwork_struct*work);staticDECLARE_WORK(slab_caches_to_rcu_destroy_work,slab_caches_to_rcu_destroy_workfn);/* * Set of flags that will prevent slab merging */#define SLAB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \ SLAB_TRACE | SLAB_TYPESAFE_BY_RCU | SLAB_NOLEAKTRACE | \ SLAB_FAILSLAB | SLAB_NO_MERGE)#define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \ SLAB_CACHE_DMA32 | SLAB_ACCOUNT)/* * Merge control. If this is set then no merging of slab caches will occur. */staticboolslab_nomerge=!IS_ENABLED(CONFIG_SLAB_MERGE_DEFAULT);staticint__initsetup_slab_nomerge(char