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.

Dependency Surface

Detected Declarations

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

Implementation Notes