Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PM: hibernate: add configurable delay for pm_test

Turn the default 5 second test delay for hibernation into a
configurable module parameter, so users can determine how
long to wait in this pseudo-hibernate state before resuming
the system.

The configurable delay parameter has been added for suspend, so
add an analogous one for hibernation.

Example (wait 30 seconds);

# echo 30 > /sys/module/hibernate/parameters/pm_test_delay
# echo core > /sys/power/pm_test

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://patch.msgid.link/20250507063520.419635-1-zhangzihuan@kylinos.cn
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Zihuan Zhang and committed by
Rafael J. Wysocki
50c9bb30 f0050a3e

+14 -2
+7
Documentation/admin-guide/kernel-parameters.txt
··· 1831 1831 lz4: Select LZ4 compression algorithm to 1832 1832 compress/decompress hibernation image. 1833 1833 1834 + hibernate.pm_test_delay= 1835 + [HIBERNATION] 1836 + Sets the number of seconds to remain in a hibernation test 1837 + mode before resuming the system (see 1838 + /sys/power/pm_test). Only available when CONFIG_PM_DEBUG 1839 + is set. Default value is 5. 1840 + 1834 1841 highmem=nn[KMG] [KNL,BOOT,EARLY] forces the highmem zone to have an exact 1835 1842 size of <nn>. This works even on boxes that have no 1836 1843 highmem otherwise. This also works to reduce highmem
+7 -2
kernel/power/hibernate.c
··· 133 133 EXPORT_SYMBOL(system_entering_hibernation); 134 134 135 135 #ifdef CONFIG_PM_DEBUG 136 + static unsigned int pm_test_delay = 5; 137 + module_param(pm_test_delay, uint, 0644); 138 + MODULE_PARM_DESC(pm_test_delay, 139 + "Number of seconds to wait before resuming from hibernation test"); 136 140 static void hibernation_debug_sleep(void) 137 141 { 138 - pr_info("debug: Waiting for 5 seconds.\n"); 139 - mdelay(5000); 142 + pr_info("hibernation debug: Waiting for %d second(s).\n", 143 + pm_test_delay); 144 + mdelay(pm_test_delay * 1000); 140 145 } 141 146 142 147 static int hibernation_test(int level)