mm/slab_common.c
Source file repositories/reference/linux-study-clean/mm/slab_common.c
File Facts
- System
- Linux kernel
- Corpus path
mm/slab_common.c- Extension
.c- Size
- 60536 bytes
- Lines
- 2222
- Domain
- Core OS
- Bucket
- Memory Management
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/slab.hlinux/mm.hlinux/poison.hlinux/interrupt.hlinux/memory.hlinux/cache.hlinux/compiler.hlinux/kfence.hlinux/module.hlinux/cpu.hlinux/uaccess.hlinux/seq_file.hlinux/dma-mapping.hlinux/swiotlb.hlinux/proc_fs.hlinux/debugfs.hlinux/kmemleak.hlinux/kasan.hasm/cacheflush.hasm/tlbflush.hasm/page.hlinux/memcontrol.hlinux/stackdepot.htrace/events/rcu.h../kernel/rcu/rcu.hinternal.hslab.htrace/events/kmem.hlinux/btf.h
Detected Declarations
struct kvfree_rcu_bulk_datastruct kfree_rcu_cpu_workstruct kfree_rcu_cpufunction setup_slab_nomergefunction setup_slab_mergefunction kmem_cache_sizefunction kmem_cache_is_duplicate_namefunction list_for_each_entryfunction kmem_cache_sanity_checkfunction kmem_cache_sanity_checkfunction calculate_alignmentfunction slab_unmergeablefunction slab_args_unmergeablefunction list_for_each_entry_reversefunction __kmem_cache_aliasfunction kmem_buckets_allocfunction kmem_cache_releasefunction slab_kmem_cache_releasefunction kmem_cache_destroyfunction kmem_cache_shrinkfunction slab_is_availablefunction kmem_obj_infofunction pr_contfunction create_boot_cachefunction create_kmalloc_cachefunction kmalloc_size_roundupfunction setup_kmalloc_cache_index_tablefunction __kmalloc_minalignfunction new_kmalloc_cachefunction create_kmalloc_cachesfunction kmalloc_fix_flagsfunction freelist_randomizefunction cache_random_seq_createfunction cache_random_seq_destroyfunction print_slabinfo_headerfunction slab_stopfunction cache_showfunction slab_showfunction dump_unreclaimable_slabfunction list_for_each_entryfunction slabinfo_openfunction slab_proc_initfunction kmallocfunction kvfree_call_rcufunction kvfree_rcu_initfunction debug_rcu_bhead_unqueuefunction krc_this_cpu_lockfunction krc_this_cpu_unlock
Annotated Snippet
module_init(slab_proc_init);
#endif /* CONFIG_SLUB_DEBUG */
/**
* kfree_sensitive - Clear sensitive information in memory before freeing
* @p: object to free memory of
*
* The memory of the object @p points to is zeroed before freed.
* If @p is %NULL, kfree_sensitive() does nothing.
*
* Note: this function zeroes the whole allocated buffer which can be a good
* deal bigger than the requested buffer size passed to kmalloc(). So be
* careful when using this function in performance sensitive code.
*/
void kfree_sensitive(const void *p)
{
size_t ks;
void *mem = (void *)p;
ks = ksize(mem);
if (ks) {
kasan_unpoison_range(mem, ks);
memzero_explicit(mem, ks);
}
kfree(mem);
}
EXPORT_SYMBOL(kfree_sensitive);
#ifdef CONFIG_BPF_SYSCALL
#include <linux/btf.h>
__bpf_kfunc_start_defs();
__bpf_kfunc struct kmem_cache *bpf_get_kmem_cache(u64 addr)
{
struct slab *slab;
if (!virt_addr_valid((void *)(long)addr))
return NULL;
slab = virt_to_slab((void *)(long)addr);
return slab ? slab->slab_cache : NULL;
}
__bpf_kfunc_end_defs();
#endif /* CONFIG_BPF_SYSCALL */
/* Tracepoints definitions. */
EXPORT_TRACEPOINT_SYMBOL(kmalloc);
EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);
EXPORT_TRACEPOINT_SYMBOL(kfree);
EXPORT_TRACEPOINT_SYMBOL(kmem_cache_free);
#ifndef CONFIG_KVFREE_RCU_BATCHED
void kvfree_call_rcu(struct rcu_head *head, void *ptr)
{
if (head) {
kasan_record_aux_stack(ptr);
call_rcu(head, kvfree_rcu_cb);
return;
}
// kvfree_rcu(one_arg) call.
might_sleep();
synchronize_rcu();
kvfree(ptr);
}
EXPORT_SYMBOL_GPL(kvfree_call_rcu);
void __init kvfree_rcu_init(void)
{
}
#else /* CONFIG_KVFREE_RCU_BATCHED */
/*
* This rcu parameter is runtime-read-only. It reflects
* a minimum allowed number of objects which can be cached
* per-CPU. Object size is equal to one page. This value
* can be changed at boot time.
*/
static int rcu_min_cached_objs = 5;
module_param(rcu_min_cached_objs, int, 0444);
// A page shrinker can ask for pages to be freed to make them
// available for other parts of the system. This usually happens
// under low memory conditions, and in that case we should also
// defer page-cache filling for a short time period.
Annotation
- Immediate include surface: `linux/slab.h`, `linux/mm.h`, `linux/poison.h`, `linux/interrupt.h`, `linux/memory.h`, `linux/cache.h`, `linux/compiler.h`, `linux/kfence.h`.
- Detected declarations: `struct kvfree_rcu_bulk_data`, `struct kfree_rcu_cpu_work`, `struct kfree_rcu_cpu`, `function setup_slab_nomerge`, `function setup_slab_merge`, `function kmem_cache_size`, `function kmem_cache_is_duplicate_name`, `function list_for_each_entry`, `function kmem_cache_sanity_check`, `function kmem_cache_sanity_check`.
- Atlas domain: Core OS / Memory Management.
- Implementation status: integration 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.