include/linux/slab.h
Source file repositories/reference/linux-study-clean/include/linux/slab.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/slab.h- Extension
.h- Size
- 53730 bytes
- Lines
- 1450
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bug.hlinux/cache.hlinux/gfp.hlinux/overflow.hlinux/types.hlinux/rcupdate.hlinux/workqueue.hlinux/percpu-refcount.hlinux/cleanup.hlinux/hash.hlinux/kasan.hlinux/alloc_tag.h
Detected Declarations
struct list_lrustruct mem_cgroupstruct kmem_cache_argsenum _slab_flag_bitsenum kmalloc_cache_typefunction __kmem_cache_createfunction parameterfunction __kmem_cache_default_argsfunction KMEM_CACHEfunction kmem_dump_objfunction arch_slab_minalignfunction kmalloc_typefunction kmalloc_indexfunction kfree_bulkfunction __alloc_sizefunction __alloc_sizefunction __alloc_sizefunction __realloc_sizefunction functionfunction __alloc_sizefunction __alloc_sizefunction kvfree_rcu_barrierfunction kvfree_rcu_barrier_on_cachefunction kfree_rcu_scheduler_running
Annotated Snippet
struct kmem_cache_args {
/**
* @align: The required alignment for the objects.
*
* %0 means no specific alignment is requested.
*/
unsigned int align;
/**
* @useroffset: Usercopy region offset.
*
* %0 is a valid offset, when @usersize is non-%0
*/
unsigned int useroffset;
/**
* @usersize: Usercopy region size.
*
* %0 means no usercopy region is specified.
*/
unsigned int usersize;
/**
* @freeptr_offset: Custom offset for the free pointer
* in caches with &SLAB_TYPESAFE_BY_RCU or @ctor
*
* By default, &SLAB_TYPESAFE_BY_RCU and @ctor caches place the free
* pointer outside of the object. This might cause the object to grow
* in size. Cache creators that have a reason to avoid this can specify
* a custom free pointer offset in their data structure where the free
* pointer will be placed.
*
* For caches with &SLAB_TYPESAFE_BY_RCU, the caller must ensure that
* the free pointer does not overlay fields required to guard against
* object recycling (See &SLAB_TYPESAFE_BY_RCU for details).
*
* For caches with @ctor, the caller must ensure that the free pointer
* does not overlay fields initialized by the constructor.
*
* Currently, only caches with &SLAB_TYPESAFE_BY_RCU or @ctor
* may specify @freeptr_offset.
*
* Using %0 as a value for @freeptr_offset is valid. If @freeptr_offset
* is specified, @use_freeptr_offset must be set %true.
*/
unsigned int freeptr_offset;
/**
* @use_freeptr_offset: Whether a @freeptr_offset is used.
*/
bool use_freeptr_offset;
/**
* @ctor: A constructor for the objects.
*
* The constructor is invoked for each object in a newly allocated slab
* page. It is the cache user's responsibility to free object in the
* same state as after calling the constructor, or deal appropriately
* with any differences between a freshly constructed and a reallocated
* object.
*
* %NULL means no constructor.
*/
void (*ctor)(void *);
/**
* @sheaf_capacity: Enable sheaves of given capacity for the cache.
*
* With a non-zero value, allocations from the cache go through caching
* arrays called sheaves. Each cpu has a main sheaf that's always
* present, and a spare sheaf that may be not present. When both become
* empty, there's an attempt to replace an empty sheaf with a full sheaf
* from the per-node barn.
*
* When no full sheaf is available, and gfp flags allow blocking, a
* sheaf is allocated and filled from slab(s) using bulk allocation.
* Otherwise the allocation falls back to the normal operation
* allocating a single object from a slab.
*
* Analogically when freeing and both percpu sheaves are full, the barn
* may replace it with an empty sheaf, unless it's over capacity. In
* that case a sheaf is bulk freed to slab pages.
*
* The sheaves do not enforce NUMA placement of objects, so allocations
* via kmem_cache_alloc_node() with a node specified other than
* NUMA_NO_NODE will bypass them.
*
* Bulk allocation and free operations also try to use the cpu sheaves
* and barn, but fallback to using slab pages directly.
*
* When slub_debug is enabled for the cache, the sheaf_capacity argument
* is ignored.
*
* %0 means no sheaves will be created.
*/
unsigned int sheaf_capacity;
Annotation
- Immediate include surface: `linux/bug.h`, `linux/cache.h`, `linux/gfp.h`, `linux/overflow.h`, `linux/types.h`, `linux/rcupdate.h`, `linux/workqueue.h`, `linux/percpu-refcount.h`.
- Detected declarations: `struct list_lru`, `struct mem_cgroup`, `struct kmem_cache_args`, `enum _slab_flag_bits`, `enum kmalloc_cache_type`, `function __kmem_cache_create`, `function parameter`, `function __kmem_cache_default_args`, `function KMEM_CACHE`, `function kmem_dump_obj`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.