kernel/crash_reserve.c
Source file repositories/reference/linux-study-clean/kernel/crash_reserve.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/crash_reserve.c- Extension
.c- Size
- 13493 bytes
- Lines
- 539
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- 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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/buildid.hlinux/init.hlinux/utsname.hlinux/vmalloc.hlinux/sizes.hlinux/kexec.hlinux/memory.hlinux/cpuhotplug.hlinux/memblock.hlinux/kmemleak.hlinux/cma.hlinux/crash_reserve.hasm/page.hasm/sections.hkallsyms_internal.hkexec_internal.h
Detected Declarations
function parse_crashkernel_memfunction parse_crashkernel_simplefunction parse_crashkernel_suffixfunction __parse_crashkernelfunction parse_crashkernelfunction parse_crashkernel_dummyfunction reserve_crashkernel_lowfunction reserve_crashkernel_genericfunction reserve_crashkernel_cmafunction reserve_crashkernel_cmafunction insert_crashkernel_resources
Annotated Snippet
if (cur == tmp) {
pr_warn("crashkernel: Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (*cur != '-') {
pr_warn("crashkernel: '-' expected\n");
return -EINVAL;
}
cur++;
/* if no ':' is here, than we read the end */
if (*cur != ':') {
end = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("crashkernel: Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (end <= start) {
pr_warn("crashkernel: end <= start\n");
return -EINVAL;
}
}
if (*cur != ':') {
pr_warn("crashkernel: ':' expected\n");
return -EINVAL;
}
cur++;
size = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("crashkernel: Memory value expected\n");
return -EINVAL;
}
cur = tmp;
if (size >= total_mem) {
pr_warn("crashkernel: invalid size\n");
return -EINVAL;
}
/* match ? */
if (total_mem >= start && total_mem < end) {
*crash_size = size;
break;
}
} while (*cur++ == ',');
if (*crash_size > 0) {
while (*cur && *cur != ' ' && *cur != '@')
cur++;
if (*cur == '@') {
cur++;
*crash_base = memparse(cur, &tmp);
if (cur == tmp) {
pr_warn("crashkernel: Memory value expected after '@'\n");
return -EINVAL;
}
}
} else
pr_info("crashkernel size resulted in zero bytes\n");
return 0;
}
/*
* That function parses "simple" (old) crashkernel command lines like
*
* crashkernel=size[@offset]
*
* It returns 0 on success and -EINVAL on failure.
*/
static int __init parse_crashkernel_simple(char *cmdline,
unsigned long long *crash_size,
unsigned long long *crash_base)
{
char *cur = cmdline;
*crash_size = memparse(cmdline, &cur);
if (cmdline == cur) {
pr_warn("crashkernel: memory value expected\n");
return -EINVAL;
}
if (*cur == '@')
*crash_base = memparse(cur+1, &cur);
else if (*cur != ' ' && *cur != '\0') {
pr_warn("crashkernel: unrecognized char: %c\n", *cur);
return -EINVAL;
Annotation
- Immediate include surface: `linux/buildid.h`, `linux/init.h`, `linux/utsname.h`, `linux/vmalloc.h`, `linux/sizes.h`, `linux/kexec.h`, `linux/memory.h`, `linux/cpuhotplug.h`.
- Detected declarations: `function parse_crashkernel_mem`, `function parse_crashkernel_simple`, `function parse_crashkernel_suffix`, `function __parse_crashkernel`, `function parse_crashkernel`, `function parse_crashkernel_dummy`, `function reserve_crashkernel_low`, `function reserve_crashkernel_generic`, `function reserve_crashkernel_cma`, `function reserve_crashkernel_cma`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: source implementation candidate.
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.