include/linux/module.h
Source file repositories/reference/linux-study-clean/include/linux/module.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/module.h- Extension
.h- Size
- 28253 bytes
- Lines
- 1027
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/stat.hlinux/buildid.hlinux/compiler.hlinux/cache.hlinux/cleanup.hlinux/kmod.hlinux/init.hlinux/elf.hlinux/stringify.hlinux/kobject.hlinux/moduleparam.hlinux/jump_label.hlinux/export.hlinux/rbtree_latch.hlinux/error-injection.hlinux/tracepoint-defs.hlinux/srcu.hlinux/static_call_types.hlinux/dynamic_debug.hlinux/percpu.hasm/module.h
Detected Declarations
struct modversion_infostruct modulestruct exception_table_entrystruct module_kobjectstruct module_attributestruct module_version_attributestruct notifier_blockstruct mod_tree_nodestruct module_memorystruct mod_kallsymsstruct klp_modinfostruct moduleenum module_stateenum mod_mem_typefunction kallsyms_symbol_valuefunction module_is_livefunction module_is_comingfunction within_module_mem_typefunction within_module_corefunction within_module_initfunction within_modulefunction try_module_getfunction module_putfunction module_requested_async_probingfunction is_livepatch_modulefunction is_module_addressfunction is_module_percpu_addressfunction __is_module_percpu_addressfunction is_module_text_addressfunction within_module_corefunction within_module_initfunction within_modulefunction __module_getfunction module_putfunction unregister_module_notifierfunction print_modulesfunction module_is_comingfunction module_for_each_modfunction module_bug_finalizefunction retpoline_module_okfunction module_sig_okfunction is_module_sig_enforcedfunction set_module_sig_enforcedfunction module_kallsyms_on_each_symbolfunction module_address_lookupfunction lookup_module_symbol_namefunction module_get_kallsymfunction module_kallsyms_lookup_name
Annotated Snippet
* module_init() - driver initialization entry point
* @x: function to be run at kernel boot time or module insertion
*
* module_init() will either be called during do_initcalls() (if
* builtin) or at module insertion time (if a module). There can only
* be one per module.
*/
#define module_init(x) __initcall(x);
/**
* module_exit() - driver exit entry point
* @x: function to be run when driver is removed
*
* module_exit() will wrap the driver clean-up code
* with cleanup_module() when used with rmmod when
* the driver is a module. If the driver is statically
* compiled into the kernel, module_exit() has no effect.
* There can only be one per module.
*/
#define module_exit(x) __exitcall(x);
#else /* MODULE */
/*
* In most cases loadable modules do not need custom
* initcall levels. There are still some valid cases where
* a driver may be needed early if built in, and does not
* matter when built as a loadable module. Like bus
* snooping debug drivers.
*/
#define early_initcall(fn) module_init(fn)
#define core_initcall(fn) module_init(fn)
#define core_initcall_sync(fn) module_init(fn)
#define postcore_initcall(fn) module_init(fn)
#define postcore_initcall_sync(fn) module_init(fn)
#define arch_initcall(fn) module_init(fn)
#define subsys_initcall(fn) module_init(fn)
#define subsys_initcall_sync(fn) module_init(fn)
#define fs_initcall(fn) module_init(fn)
#define fs_initcall_sync(fn) module_init(fn)
#define rootfs_initcall(fn) module_init(fn)
#define device_initcall(fn) module_init(fn)
#define device_initcall_sync(fn) module_init(fn)
#define late_initcall(fn) module_init(fn)
#define late_initcall_sync(fn) module_init(fn)
#define console_initcall(fn) module_init(fn)
/* Each module must use one module_init(). */
#define module_init(initfn) \
static inline initcall_t __maybe_unused __inittest(void) \
{ return initfn; } \
int init_module(void) __copy(initfn) \
__attribute__((alias(#initfn))); \
___ADDRESSABLE(init_module, __initdata);
/* This is only required if you want to be unloadable. */
#define module_exit(exitfn) \
static inline exitcall_t __maybe_unused __exittest(void) \
{ return exitfn; } \
void cleanup_module(void) __copy(exitfn) \
__attribute__((alias(#exitfn))); \
___ADDRESSABLE(cleanup_module, __exitdata);
#endif
/* This means "can be init if no module support, otherwise module load
may call it." */
#ifdef CONFIG_MODULES
#define __init_or_module
#define __initdata_or_module
#define __initconst_or_module
#else
#define __init_or_module __init
#define __initdata_or_module __initdata
#define __initconst_or_module __initconst
#endif /*CONFIG_MODULES*/
struct module_kobject *lookup_or_create_module_kobject(const char *name);
/* For userspace: you can also call me... */
#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
/* Soft module dependencies. See man modprobe.d for details.
* Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
*/
#define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep)
/*
* Weak module dependencies. See man modprobe.d for details.
Annotation
- Immediate include surface: `linux/list.h`, `linux/stat.h`, `linux/buildid.h`, `linux/compiler.h`, `linux/cache.h`, `linux/cleanup.h`, `linux/kmod.h`, `linux/init.h`.
- Detected declarations: `struct modversion_info`, `struct module`, `struct exception_table_entry`, `struct module_kobject`, `struct module_attribute`, `struct module_version_attribute`, `struct notifier_block`, `struct mod_tree_node`, `struct module_memory`, `struct mod_kallsyms`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.