Skip to contentSkip to conversation

: Improve performance of LZO/plain hibernation, check image with CRC32

PATCH Superseded Bojan Smojver 1 participant 1 message Oct 9, 2011

Subsystems (2)

v9 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

PATCH v9 1/1 : Improve performance of LZO/plain hibernation, check image with CRC32

In order to make sure we are reading in what we wrote, the patch now features calculation and checking of CRC32. This is done in a backward compatible manner - if the flag is not set on disk to do this, we don't check it. Note that it only applies to hibernation when compression is used. (Note: SHA1 was way to slow, so I ditched that approach for now.)

Also, thanks to Dan Carpenter for pointing out memory deallocation problems. They are (hopefully) fixed now.

A problem where handle->cur page may have been deallocated twice, when loading of the image failed, has been fixed.

Some of the vmalloc() calls have been replaced with kmalloc(). There is no point wasting whole pages for small structures.

Also, some of the variables have been converted from size_t to unsigned (on x86_64, this means from 64-bit down to 32-bit). Really no point keeping number of pages used for compression/decompression/buffering and number of threads in 64-bit format. There is no way we should every have that many of those things.

Finally, in an effort to facilitate easier copying of code between save/load functions, some of the variables named error were renamed to ret.

---------------------------------------
Use threads for LZO compression/decompression on hibernate/thaw. Improve buffering on hibernate/thaw.
Calculate/verify CRC32 of the image pages on hibernate/thaw. v9

In my testing, this improved write/read speed by a factor of about two.

---
 kernel/power/Kconfig     |    1 +
 kernel/power/hibernate.c |    3 +
 kernel/power/power.h     |    1 +
 kernel/power/swap.c      |  818 ++++++++++++++++++++++++++++++++++++----------
 4 files changed, 644 insertions(+), 179 deletions(-)
kernel/power/Kconfig +1 -0
index 3744c59..e675045 100644
@@ -27,6 +27,7 @@ config HIBERNATION
 	select HIBERNATE_CALLBACKS
 	select LZO_COMPRESS
 	select LZO_DECOMPRESS
+	select CRC32
 	---help---
 	  Enable the suspend to disk (STD) functionality, which is usually
 	  called "hibernation" in user interfaces.  STD checkpoints the
kernel/power/hibernate.c +3 -0
index 8f7b1db..6363d6b 100644
@@ -650,6 +650,9 @@ int hibernate(void)
 			flags |= SF_PLATFORM_MODE;
 		if (nocompress)
 			flags |= SF_NOCOMPRESS_MODE;
+                else
+		        flags |= SF_CRC32_MODE;
+
 		pr_debug("PM: writing image.\n");
 		error = swsusp_write(flags);
 		swsusp_free();
kernel/power/power.h +1 -0
index 9a00a0a..f543583 100644
@@ -146,6 +146,7 @@ extern int swsusp_swap_in_use(void);
  */
 #define SF_PLATFORM_MODE	1
 #define SF_NOCOMPRESS_MODE	2
+#define SF_CRC32_MODE	        4
 
 /* kernel/power/hibernate.c */
 extern int swsusp_check(void);
kernel/power/swap.c +639 -179

1,068 lines not on this page · raw message

---------------------------------------

Signature · 1 line
Bojan