[PATCH] initramfs: allow again choice of the embedded compression algorithm
From: klondike
Date: Thu Sep 25 2014 - 00:47:53 EST
Choosing the appropriate option (for example on my tests, choosing
CONFIG_INITRAMFS_COMPRESSION_NONE when compressing the using XZ) results in
up to 500KiB differences (9MiB to 8.5MiB) in the kernel size as the
dictionary
will not get polluted with uncomprensible data and may reuse kernel data
too.
Despite embedding an uncompressed initramfs, a user may want to allow for a
compressed extra initramfs to be passed using the rd system, for example to
boot a recovery system. Commit 9ba4bcb645898d562498ea66a0df958ef0e7a68c
("initramfs: read CONFIG_RD_ variables for initramfs compression") broke
that behavior by making the choice based on CONFIG_RD_* instead of adding
CONFIG_INITRAMFS_COMPRESSION_LZ4. Saddly, CONFIG_RD_* is also used to
choose the supported RD compression algorithms by the kernel and a user may
want to suppport more than one.
This patch also reverses 3e4e0f0a8756dade3023d1f47d50fbced7749788
("initramfs:
remove "compression mode" choice") restoring back the "compression mode"
choice and includes the CONFIG_INITRAMFS_COMPRESSION_LZ4 option which was
never added.
As a result the following options are added or readed affecting the embedded
initramfs compression:
INITRAMFS_COMPRESSION_NONE Do no compression
INITRAMFS_COMPRESSION_GZIP Compress using gzip
INITRAMFS_COMPRESSION_BZIP2 Compress using bzip2
INITRAMFS_COMPRESSION_LZMA Compress using lzma
INITRAMFS_COMPRESSION_XZ Compress using xz
INITRAMFS_COMPRESSION_LZO Compress using lzo
INITRAMFS_COMPRESSION_LZ4 Compress using lz4
These depend on the corresponding CONFIG_RD_* option (except NONE which
has no
dependencies).
Signed-off-by: Francisco Blas Izquierdo Riera (klondike)
<klondike@xxxxxxxxxxx>
Cc: P J P <ppandit@xxxxxxxxxx>
Cc: Paul Bolle <pebolle@xxxxxxxxxx>
---
This patch is applied against Torvald's linux tree
Note: scripts/checkpatch.pl complains about style:
"WARNING: please write a paragraph that describes the config symbol fully"
this seems to be a false positive.
usr/Kconfig | 85
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
usr/Makefile | 13 +++++++------
2 files changed, 92 insertions(+), 6 deletions(-)
diff --git a/usr/Kconfig b/usr/Kconfig
index 2d4c77e..09de7b9 100644
--- a/usr/Kconfig
+++ b/usr/Kconfig
@@ -98,3 +98,88 @@ config RD_LZ4
help
Support loading of a LZ4 encoded initial ramdisk or cpio buffer
If unsure, say N.
+
+choice
+ prompt "Built-in initramfs compression mode" if INITRAMFS_SOURCE!=""
+ help
+ This option decides by which algorithm the builtin initramfs
+ will be compressed. Several compression algorithms are
+ available, which differ in efficiency, compression and
+ decompression speed. Compression speed is only relevant
+ when building a kernel. Decompression speed is relevant at
+ each boot.
+
+ If you have any problems with bzip2 or LZMA compressed
+ initramfs, mail me (Alain Knaff) <alain@xxxxxxxx>.
+
+ High compression options are mostly useful for users who are
+ low on RAM, since it reduces the memory consumption during
+ boot.
+
+ If in doubt, select 'gzip'
+
+config INITRAMFS_COMPRESSION_NONE
+ bool "None"
+ help
+ Do not compress the built-in initramfs at all. This may
+ sound wasteful in space, but, you should be aware that the
+ built-in initramfs will be compressed at a later stage
+ anyways along with the rest of the kernel, on those
+ architectures that support this.
+ However, not compressing the initramfs may lead to slightly
+ higher memory consumption during a short time at boot, while
+ both the cpio image and the unpacked filesystem image will
+ be present in memory simultaneously
+
+config INITRAMFS_COMPRESSION_GZIP
+ bool "Gzip"
+ depends on RD_GZIP
+ help
+ The old and tried gzip compression. It provides a good balance
+ between compression ratio and decompression speed.
+
+config INITRAMFS_COMPRESSION_BZIP2
+ bool "Bzip2"
+ depends on RD_BZIP2
+ help
+ Its compression ratio and speed is intermediate.
+ Decompression speed is slowest among the choices. The initramfs
+ size is about 10% smaller with bzip2, in comparison to gzip.
+ Bzip2 uses a large amount of memory. For modern kernels you
+ will need at least 8MB RAM or more for booting.
+
+config INITRAMFS_COMPRESSION_LZMA
+ bool "LZMA"
+ depends on RD_LZMA
+ help
+ This algorithm's compression ratio is best.
+ Decompression speed is between the other choices.
+ Compression is slowest. The initramfs size is about 33%
+ smaller with LZMA in comparison to gzip.
+
+config INITRAMFS_COMPRESSION_XZ
+ bool "XZ"
+ depends on RD_XZ
+ help
+ XZ uses the LZMA2 algorithm. The initramfs size is about 30%
+ smaller with XZ in comparison to gzip. Decompression speed
+ is better than that of bzip2 but worse than gzip and LZO.
+ Compression is slow.
+
+config INITRAMFS_COMPRESSION_LZO
+ bool "LZO"
+ depends on RD_LZO
+ help
+ Its compression ratio is the second poorest among the choices. The
+ kernel size is about 10% bigger than gzip; however its decompression
+ speed is the second fastest.
+
+config INITRAMFS_COMPRESSION_LZ4
+ bool "LZ4"
+ depends on RD_LZ4
+ help
+ Its compression ratio is the poorest among the choices. The kernel
+ size is about 15% bigger than gzip; however its decompression speed
+ is the fastest.
+
+endchoice
diff --git a/usr/Makefile b/usr/Makefile
index e767f01..4031e23 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -5,24 +5,25 @@
klibcdirs:;
PHONY += klibcdirs
+#If unset it means we use CONFIG_INITRAMFS_COMPRESSION_NONE
# Bzip2
-suffix_$(CONFIG_RD_BZIP2) = .bz2
+suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2
# Lzma
-suffix_$(CONFIG_RD_LZMA) = .lzma
+suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
# XZ
-suffix_$(CONFIG_RD_XZ) = .xz
+suffix_$(CONFIG_INITRAMFS_COMPRESSION_XZ) = .xz
# Lzo
-suffix_$(CONFIG_RD_LZO) = .lzo
+suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZO) = .lzo
# Lz4
-suffix_$(CONFIG_RD_LZ4) = .lz4
+suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZ4) = .lz4
# Gzip
-suffix_$(CONFIG_RD_GZIP) = .gz
+suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz
AFLAGS_initramfs_data.o +=
-DINITRAMFS_IMAGE="usr/initramfs_data.cpio$(suffix_y)"
Attachment:
signature.asc
Description: OpenPGP digital signature