Skip to content

Commit f996fc9

Browse files
bsmojverrjwysocki
authored andcommitted
PM / Hibernate: Compress hibernation image with LZO
Compress hibernation image with LZO in order to save on I/O and therefore time to hibernate/thaw. [rjw: Added hibernate=nocompress command line option instead of just nocompress which would be confusing, fixed a couple of compiler warnings, fixed kerneldoc comments, minor cleanups.] Signed-off-by: Bojan Smojver <bojan@rexursive.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
1 parent 05aa55d commit f996fc9

6 files changed

Lines changed: 306 additions & 8 deletions

File tree

‎Documentation/kernel-parameters.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,6 +2165,11 @@ and is between 256 and 4096 characters. It is defined in the file
21652165
in <PAGE_SIZE> units (needed only for swap files).
21662166
See Documentation/power/swsusp-and-swap-files.txt
21672167

2168+
hibernate= [HIBERNATION]
2169+
noresume Don't check if there's a hibernation image
2170+
present during boot.
2171+
nocompress Don't compress/decompress hibernation images.
2172+
21682173
retain_initrd [RAM] Keep initrd memory after extraction
21692174

21702175
rhash_entries= [KNL,NET]

‎Documentation/power/swsusp.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ swsusp saves the state of the machine into active swaps and then reboots or
6666
powerdowns. You must explicitly specify the swap partition to resume from with
6767
``resume='' kernel option. If signature is found it loads and restores saved
6868
state. If the option ``noresume'' is specified as a boot parameter, it skips
69-
the resuming.
69+
the resuming. If the option ``hibernate=nocompress'' is specified as a boot
70+
parameter, it saves hibernation image without compression.
7071

7172
In the meantime while the system is suspended you should not add/remove any
7273
of the hardware, write to the filesystems, etc.

‎kernel/power/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ config SUSPEND_FREEZER
137137
config HIBERNATION
138138
bool "Hibernation (aka 'suspend to disk')"
139139
depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
140+
select LZO_COMPRESS
141+
select LZO_DECOMPRESS
140142
select SUSPEND_NVS if HAS_IOMEM
141143
---help---
142144
Enable the suspend to disk (STD) functionality, which is usually

‎kernel/power/hibernate.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "power.h"
3030

3131

32+
static int nocompress = 0;
3233
static int noresume = 0;
3334
static char resume_file[256] = CONFIG_PM_STD_PARTITION;
3435
dev_t swsusp_resume_device;
@@ -638,6 +639,8 @@ int hibernate(void)
638639

639640
if (hibernation_mode == HIBERNATION_PLATFORM)
640641
flags |= SF_PLATFORM_MODE;
642+
if (nocompress)
643+
flags |= SF_NOCOMPRESS_MODE;
641644
pr_debug("PM: writing image.\n");
642645
error = swsusp_write(flags);
643646
swsusp_free();
@@ -1004,6 +1007,15 @@ static int __init resume_offset_setup(char *str)
10041007
return 1;
10051008
}
10061009

1010+
static int __init hibernate_setup(char *str)
1011+
{
1012+
if (!strncmp(str, "noresume", 8))
1013+
noresume = 1;
1014+
else if (!strncmp(str, "nocompress", 10))
1015+
nocompress = 1;
1016+
return 1;
1017+
}
1018+
10071019
static int __init noresume_setup(char *str)
10081020
{
10091021
noresume = 1;
@@ -1013,3 +1025,4 @@ static int __init noresume_setup(char *str)
10131025
__setup("noresume", noresume_setup);
10141026
__setup("resume_offset=", resume_offset_setup);
10151027
__setup("resume=", resume_setup);
1028+
__setup("hibernate=", hibernate_setup);

‎kernel/power/power.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ extern int swsusp_swap_in_use(void);
134134
* the image header.
135135
*/
136136
#define SF_PLATFORM_MODE 1
137+
#define SF_NOCOMPRESS_MODE 2
137138

138139
/* kernel/power/hibernate.c */
139140
extern int swsusp_check(void);

0 commit comments

Comments
 (0)