kernel/module/stats.c
Source file repositories/reference/linux-study-clean/kernel/module/stats.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/module/stats.c- Extension
.c- Size
- 18197 bytes
- Lines
- 433
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/module.huapi/linux/module.hlinux/string.hlinux/printk.hlinux/slab.hlinux/list.hlinux/debugfs.hlinux/rculist.hlinux/math.hinternal.h
Detected Declarations
function mod_stat_bump_invalidfunction mod_stat_bump_becomingfunction try_add_failed_modulefunction list_for_each_entry_rcufunction read_file_mod_statsfunction list_for_each_entry_rcufunction module_stats_initmodule init module_stats_init
Annotated Snippet
static const struct file_operations fops_mod_stats = {
.read = read_file_mod_stats,
.open = simple_open,
.owner = THIS_MODULE,
.llseek = default_llseek,
};
#define mod_debug_add_ulong(name) debugfs_create_ulong(#name, 0400, mod_debugfs_root, (unsigned long *) &name.counter)
#define mod_debug_add_atomic(name) debugfs_create_atomic_t(#name, 0400, mod_debugfs_root, &name)
static int __init module_stats_init(void)
{
mod_debug_add_ulong(total_mod_size);
mod_debug_add_ulong(total_text_size);
mod_debug_add_ulong(invalid_kread_bytes);
mod_debug_add_ulong(invalid_decompress_bytes);
mod_debug_add_ulong(invalid_becoming_bytes);
mod_debug_add_ulong(invalid_mod_bytes);
mod_debug_add_atomic(modcount);
mod_debug_add_atomic(failed_kreads);
mod_debug_add_atomic(failed_decompress);
mod_debug_add_atomic(failed_becoming);
mod_debug_add_atomic(failed_load_modules);
debugfs_create_file("stats", 0400, mod_debugfs_root, mod_debugfs_root, &fops_mod_stats);
return 0;
}
#undef mod_debug_add_ulong
#undef mod_debug_add_atomic
module_init(module_stats_init);
Annotation
- Immediate include surface: `linux/module.h`, `uapi/linux/module.h`, `linux/string.h`, `linux/printk.h`, `linux/slab.h`, `linux/list.h`, `linux/debugfs.h`, `linux/rculist.h`.
- Detected declarations: `function mod_stat_bump_invalid`, `function mod_stat_bump_becoming`, `function try_add_failed_module`, `function list_for_each_entry_rcu`, `function read_file_mod_stats`, `function list_for_each_entry_rcu`, `function module_stats_init`, `module init module_stats_init`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern 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.