Skip to content

Commit

Permalink
usr: Add support for zstd compressed initramfs
Browse files Browse the repository at this point in the history
- Add support for a zstd compressed initramfs.

- Add compression for compressing built-in initramfs with zstd.

I have tested this patch by boot testing with buildroot and QEMU.
Specifically, I booted the kernel with both a zstd and gzip compressed
initramfs, both built into the kernel and separate. I ensured that the
correct compression algorithm was used. I tested on arm, aarch64, i386,
and x86_64.

This patch has been tested in production on aarch64 and x86_64 devices.

Additionally, I have performance measurements from internal use in
production. On an aarch64 device we saw 19 second boot time improvement
from switching from lzma to zstd (27 seconds to 8 seconds). On an x86_64
device we saw a 9 second boot time reduction from switching from xz to
zstd.

Signed-off-by: Nick Terrell <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Tested-by: Sedat Dilek <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
terrelln authored and Ingo Molnar committed Jul 31, 2020
1 parent 48f7ddf commit a30d8a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions usr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ config RD_LZ4
Support loading of a LZ4 encoded initial ramdisk or cpio buffer
If unsure, say N.

config RD_ZSTD
bool "Support initial ramdisk/ramfs compressed using ZSTD"
default y
depends on BLK_DEV_INITRD
select DECOMPRESS_ZSTD
help
Support loading of a ZSTD encoded initial ramdisk or cpio buffer.
If unsure, say N.

choice
prompt "Built-in initramfs compression mode"
depends on INITRAMFS_SOURCE != ""
Expand Down Expand Up @@ -196,6 +205,17 @@ config INITRAMFS_COMPRESSION_LZ4
If you choose this, keep in mind that most distros don't provide lz4
by default which could cause a build failure.

config INITRAMFS_COMPRESSION_ZSTD
bool "ZSTD"
depends on RD_ZSTD
help
ZSTD is a compression algorithm targeting intermediate compression
with fast decompression speed. It will compress better than GZIP and
decompress around the same speed as LZO, but slower than LZ4.

If you choose this, keep in mind that you may need to install the zstd
tool to be able to compress the initram.

config INITRAMFS_COMPRESSION_NONE
bool "None"
help
Expand Down
1 change: 1 addition & 0 deletions usr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ compress-$(CONFIG_INITRAMFS_COMPRESSION_LZMA) := lzma
compress-$(CONFIG_INITRAMFS_COMPRESSION_XZ) := xzmisc
compress-$(CONFIG_INITRAMFS_COMPRESSION_LZO) := lzo
compress-$(CONFIG_INITRAMFS_COMPRESSION_LZ4) := lz4
compress-$(CONFIG_INITRAMFS_COMPRESSION_ZSTD) := zstd

obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o

Expand Down

0 comments on commit a30d8a3

Please sign in to comment.