fs/proc/vmcore.c
Source file repositories/reference/linux-study-clean/fs/proc/vmcore.c
File Facts
- System
- Linux kernel
- Corpus path
fs/proc/vmcore.c- Extension
.c- Size
- 46258 bytes
- Lines
- 1757
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- 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/mm.hlinux/kcore.hlinux/user.hlinux/elf.hlinux/elfcore.hlinux/export.hlinux/slab.hlinux/highmem.hlinux/printk.hlinux/memblock.hlinux/init.hlinux/crash_dump.hlinux/list.hlinux/moduleparam.hlinux/mutex.hlinux/vmalloc.hlinux/pagemap.hlinux/uio.hlinux/cc_platform.hasm/io.hinternal.h
Detected Declarations
struct vmcoredd_nodefunction register_vmcore_cbfunction unregister_vmcore_cbfunction pfn_is_ramfunction list_for_each_entry_srcufunction open_vmcorefunction release_vmcorefunction read_from_oldmemfunction elfcorehdr_allocfunction elfcorehdr_freefunction elfcorehdr_read_notesfunction remap_oldmem_pfn_rangefunction copy_oldmem_page_encryptedfunction vmcoredd_copy_dumpsfunction list_for_each_entryfunction vmcoredd_mmap_dumpsfunction list_for_each_entryfunction __read_vmcorefunction list_for_each_entryfunction read_vmcorefunction mmap_vmcorefunction remap_oldmem_pfn_checkedfunction vmcore_remap_oldmem_pfnfunction mmap_vmcorefunction list_for_each_entryfunction mmap_vmcorefunction get_vmcore_sizefunction update_note_header_size_elf64function get_note_number_and_size_elf64function copy_notes_elf64function merge_note_headers_elf64function update_note_header_size_elf32function get_note_number_and_size_elf32function copy_notes_elf32function merge_note_headers_elf32function process_ptload_program_headers_elf64function process_ptload_program_headers_elf32function set_vmcore_list_offsetsfunction list_for_each_entryfunction free_elfcorebuffunction parse_crash_elf64_headersfunction parse_crash_elf32_headersfunction parse_crash_elf_headersfunction vmcoredd_write_headerfunction headerfunction vmcoredd_update_sizefunction vmcore_add_device_dumpfunction vmcore_realloc_elfcore_buffer_elf64
Annotated Snippet
struct vmcoredd_node {
struct list_head list; /* List of dumps */
void *buf; /* Buffer containing device's dump */
unsigned int size; /* Size of the buffer */
};
/* Device Dump list and mutex to synchronize access to list */
static LIST_HEAD(vmcoredd_list);
static bool vmcoredd_disabled;
core_param(novmcoredd, vmcoredd_disabled, bool, 0);
#endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */
/* Device Dump Size */
static size_t vmcoredd_orig_sz;
static DEFINE_MUTEX(vmcore_mutex);
DEFINE_STATIC_SRCU(vmcore_cb_srcu);
/* List of registered vmcore callbacks. */
static LIST_HEAD(vmcore_cb_list);
/* Whether the vmcore has been opened once. */
static bool vmcore_opened;
/* Whether the vmcore is currently open. */
static unsigned int vmcore_open;
static void vmcore_process_device_ram(struct vmcore_cb *cb);
void register_vmcore_cb(struct vmcore_cb *cb)
{
INIT_LIST_HEAD(&cb->next);
mutex_lock(&vmcore_mutex);
list_add_tail(&cb->next, &vmcore_cb_list);
/*
* Registering a vmcore callback after the vmcore was opened is
* very unusual (e.g., manual driver loading).
*/
if (vmcore_opened)
pr_warn_once("Unexpected vmcore callback registration\n");
if (!vmcore_open && cb->get_device_ram)
vmcore_process_device_ram(cb);
mutex_unlock(&vmcore_mutex);
}
EXPORT_SYMBOL_GPL(register_vmcore_cb);
void unregister_vmcore_cb(struct vmcore_cb *cb)
{
mutex_lock(&vmcore_mutex);
list_del_rcu(&cb->next);
/*
* Unregistering a vmcore callback after the vmcore was opened is
* very unusual (e.g., forced driver removal), but we cannot stop
* unregistering.
*/
if (vmcore_opened)
pr_warn_once("Unexpected vmcore callback unregistration\n");
mutex_unlock(&vmcore_mutex);
synchronize_srcu(&vmcore_cb_srcu);
}
EXPORT_SYMBOL_GPL(unregister_vmcore_cb);
static bool pfn_is_ram(unsigned long pfn)
{
struct vmcore_cb *cb;
bool ret = true;
list_for_each_entry_srcu(cb, &vmcore_cb_list, next,
srcu_read_lock_held(&vmcore_cb_srcu)) {
if (unlikely(!cb->pfn_is_ram))
continue;
ret = cb->pfn_is_ram(cb, pfn);
if (!ret)
break;
}
return ret;
}
static int open_vmcore(struct inode *inode, struct file *file)
{
mutex_lock(&vmcore_mutex);
vmcore_opened = true;
if (vmcore_open + 1 == 0) {
mutex_unlock(&vmcore_mutex);
return -EBUSY;
}
vmcore_open++;
mutex_unlock(&vmcore_mutex);
Annotation
- Immediate include surface: `linux/mm.h`, `linux/kcore.h`, `linux/user.h`, `linux/elf.h`, `linux/elfcore.h`, `linux/export.h`, `linux/slab.h`, `linux/highmem.h`.
- Detected declarations: `struct vmcoredd_node`, `function register_vmcore_cb`, `function unregister_vmcore_cb`, `function pfn_is_ram`, `function list_for_each_entry_srcu`, `function open_vmcore`, `function release_vmcore`, `function read_from_oldmem`, `function elfcorehdr_alloc`, `function elfcorehdr_free`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.