Skip to content

RFC PM: hibernate: LZ4 compression support

Nikhil V linux-doc linux-pm lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4PM: hibernate: Rename lzo* to make it generickernel/power/swap.c+61 -610 replies
2/4PM: hibernate: Move to crypto APIs for LZO compressionkernel/power/Kconfig kernel/power/hibernate.c kernel/power/power.h +1 more+131 -280 replies
3/4PM: hibernate: Add support for LZ4 compression for hibernationkernel/power/Kconfig kernel/power/hibernate.c kernel/power/power.h+41 -30 replies
4/4PM: hibernate: Support to select compression algorithmDocumentation/admin-guide/kernel-parameters.txt kernel/power/hibernate.c+34 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/4] PM: hibernate: LZ4 compression support

This patch series covers the following:
1. Renaming lzo* to generic names, except for lzo_xxx() APIs. This is used in the next patch where we move to crypto based APIs for compression. There are no functional changes introduced by this approach.

2. Replace LZO library calls with crypto generic APIs

Currently for hibernation, LZO is the only compression algorithm available and uses the existing LZO library calls. However, there is no flexibility to switch to other algorithms which provides better results. The main idea is that different compression algorithms have different characteristics and hibernation may benefit when it uses alternate algorithms.

By moving to crypto based APIs, it lays a foundation to use other compression algorithms for hibernation.

3. LZ4 compression
Extend the support for LZ4 compression to be used with hibernation. The main idea is that different compression algorithms
have different characteristics and hibernation may benefit when it uses any of these algorithms: a default algorithm, having higher compression rate but is slower(compression/decompression) and a secondary algorithm, that is faster(compression/decompression) but has lower compression rate.

LZ4 algorithm has better decompression speeds over LZO. This reduces the hibernation image restore time.
As per test results:
LZO LZ4

Size before Compression(bytes)   682696704       682393600
Size after Compression(bytes)    146502402       155993547
Decompression Rate               335.02 MB/s     501.05 MB/s

Restore time 4.4s 3.8s

LZO is the default compression algorithm used for hibernation. Enable CONFIG_HIBERNATION_DEF_COMP_LZ4 to set the default compressor as LZ4.

Compression Benchmarks: https://github.com/lz4/lz4

4. Support to select compression algorithm

Currently the default compression algorithm is selected based on Kconfig. Introduce a kernel command line parameter "hib_compression" to override this behaviour.

Users can set "hib_compression" command line parameter to specify the algorithm.
Usage:
LZO: hib_compression=lzo
LZ4: hib_compression=lz4
LZO is the default compression algorithm used with hibernation.

Nikhil V (4):
PM: hibernate: Rename lzo* to make it generic
PM: hibernate: Move to crypto APIs for LZO compression
PM: hibernate: Add support for LZ4 compression for hibernation
PM: hibernate: Support to select compression algorithm

 .../admin-guide/kernel-parameters.txt         |   6 +
 kernel/power/Kconfig                          |  25 ++-
 kernel/power/hibernate.c                      |  83 +++++++-
 kernel/power/power.h                          |  19 ++
 kernel/power/swap.c                           | 189 +++++++++++-------
 5 files changed, 248 insertions(+), 74 deletions(-)
Signature · 1 line
2.17.1