kernel/power/hibernate.c
Source file repositories/reference/linux-study-clean/kernel/power/hibernate.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/power/hibernate.c- Extension
.c- Size
- 35262 bytes
- Lines
- 1525
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- 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
crypto/acompress.hlinux/blkdev.hlinux/export.hlinux/suspend.hlinux/reboot.hlinux/string.hlinux/device.hlinux/async.hlinux/delay.hlinux/fs.hlinux/mount.hlinux/pm.hlinux/nmi.hlinux/console.hlinux/cpu.hlinux/freezer.hlinux/gfp.hlinux/syscore_ops.hlinux/ctype.hlinux/ktime.hlinux/security.hlinux/secretmem.htrace/events/power.hpower.h
Detected Declarations
function pm_hibernation_mode_is_suspendfunction hibernate_acquirefunction hibernate_releasefunction hibernation_in_progressfunction hibernation_availablefunction hibernation_set_opsfunction system_entering_hibernationfunction hibernation_debug_sleepfunction hibernation_testfunction hibernation_testfunction platform_beginfunction platform_endfunction platform_pre_snapshotfunction platform_leavefunction platform_preparefunction platform_restore_cleanupfunction platform_pre_restorefunction platform_recoverfunction swsusp_show_speedfunction arch_resume_nosmtfunction create_imagefunction hibernation_snapshotfunction hibernate_resume_nonboot_cpu_disablefunction resume_target_kernelfunction hibernation_snapshotfunction hibernation_platform_enterfunction power_downfunction load_image_and_restorefunction hibernatefunction hibernate_quiet_execfunction find_resume_devicefunction software_resumefunction hibernation_snapshotfunction optionfunction disk_storefunction resume_showfunction resume_storefunction resume_offset_showfunction resume_offset_storefunction image_size_showfunction image_size_storefunction reserved_size_showfunction reserved_size_storefunction pm_disk_initfunction resume_setupfunction resume_offset_setupfunction hibernate_setupfunction noresume_setup
Annotated Snippet
core_initcall(pm_disk_init);
static int __init resume_setup(char *str)
{
if (noresume)
return 1;
strscpy(resume_file, str);
return 1;
}
static int __init resume_offset_setup(char *str)
{
unsigned long long offset;
if (noresume)
return 1;
if (sscanf(str, "%llu", &offset) == 1)
swsusp_resume_block = offset;
return 1;
}
static int __init hibernate_setup(char *str)
{
if (!strncmp(str, "noresume", 8)) {
noresume = 1;
} else if (!strncmp(str, "nocompress", 10)) {
nocompress = 1;
} else if (!strncmp(str, "no", 2)) {
noresume = 1;
nohibernate = 1;
} else if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)
&& !strncmp(str, "protect_image", 13)) {
enable_restore_image_protection();
}
return 1;
}
static int __init noresume_setup(char *str)
{
noresume = 1;
return 1;
}
static int __init resumewait_setup(char *str)
{
resume_wait = 1;
return 1;
}
static int __init resumedelay_setup(char *str)
{
int rc = kstrtouint(str, 0, &resume_delay);
if (rc)
pr_warn("resumedelay: bad option string '%s'\n", str);
return 1;
}
static int __init nohibernate_setup(char *str)
{
noresume = 1;
nohibernate = 1;
return 1;
}
static const char * const comp_alg_enabled[] = {
#if IS_ENABLED(CONFIG_CRYPTO_LZO)
COMPRESSION_ALGO_LZO,
#endif
#if IS_ENABLED(CONFIG_CRYPTO_LZ4)
COMPRESSION_ALGO_LZ4,
#endif
};
static int hibernate_compressor_param_set(const char *compressor,
const struct kernel_param *kp)
{
int index, ret;
if (!mutex_trylock(&system_transition_mutex))
return -EBUSY;
index = sysfs_match_string(comp_alg_enabled, compressor);
if (index >= 0) {
ret = param_set_copystring(comp_alg_enabled[index], kp);
if (!ret)
Annotation
- Immediate include surface: `crypto/acompress.h`, `linux/blkdev.h`, `linux/export.h`, `linux/suspend.h`, `linux/reboot.h`, `linux/string.h`, `linux/device.h`, `linux/async.h`.
- Detected declarations: `function pm_hibernation_mode_is_suspend`, `function hibernate_acquire`, `function hibernate_release`, `function hibernation_in_progress`, `function hibernation_available`, `function hibernation_set_ops`, `function system_entering_hibernation`, `function hibernation_debug_sleep`, `function hibernation_test`, `function hibernation_test`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.