Bug ID | 1135854 |
---|---|
Summary | Compressing kernel modules (turn on MODULE_COMPRESS_XZ)? |
Classification | openSUSE |
Product | openSUSE Tumbleweed |
Version | Current |
Hardware | Other |
OS | Other |
Status | NEW |
Severity | Normal |
Priority | P5 - None |
Component | Kernel |
Assignee | kernel-maintainers@forge.provo.novell.com |
Reporter | jslaby@suse.com |
QA Contact | qa-bugs@suse.de |
CC | mkubecek@suse.com, tiwai@suse.com |
Found By | --- |
Blocker | --- |
I'm in favor of enabling module compression in master & stable branches. =============== init/Kconfig =============== config MODULE_COMPRESS bool "Compress modules on installation" depends on MODULES help Compresses kernel modules when 'make modules_install' is run; gzip or xz depending on "Compression algorithm" below. module-init-tools MAY support gzip, and kmod MAY support gzip and xz. Out-of-tree kernel modules installed using Kbuild will also be compressed upon installation. Note: for modules inside an initrd or initramfs, it's more efficient to compress the whole initrd or initramfs instead. Note: This is fully compatible with signed modules. If in doubt, say N. =============== EOF =============== In particular I would go for config MODULE_COMPRESS_XZ. It saves a lot of space: - Size : 364828674 + Size : 143548638 Surprisingly, it makes the system startup faster (systemd-analyze output of 2x3 boots): compressed ========== Startup finished in 2.059s (kernel) + 9.492s (initrd) + 7.496s (userspace) = 19.049s multi-user.target reached after 7.482s in userspace Startup finished in 2.117s (kernel) + 9.977s (initrd) + 7.483s (userspace) = 19.578s multi-user.target reached after 7.469s in userspace Startup finished in 2.113s (kernel) + 10.356s (initrd) + 7.733s (userspace) = 20.203s multi-user.target reached after 7.719s in userspace non-compressed ============== Startup finished in 3.848s (kernel) + 9.932s (initrd) + 8.446s (userspace) = 22.227s multi-user.target reached after 8.422s in userspace Startup finished in 3.910s (kernel) + 10.519s (initrd) + 8.155s (userspace) = 22.584s multi-user.target reached after 8.130s in userspace Startup finished in 3.901s (kernel) + 8.572s (initrd) + 8.801s (userspace) = 21.275s multi-user.target reached after 8.766s in userspace ============================================ Note that the modules are stored untouched (i.e. compressed individually) in initrd by dracut now. This should be perhaps changed: Size of initrd with *.ko.xz in initrd: 10758844 Size of initrd with *.ko in initrd: 10611448 *.ko in initrd and *.ko.xz on disk ================================== Startup finished in 2.056s (kernel) + 9.665s (initrd) + 7.322s (userspace) = 19.044s multi-user.target reached after 7.298s in userspace Startup finished in 2.037s (kernel) + 8.131s (initrd) + 7.307s (userspace) = 17.476s multi-user.target reached after 7.294s in userspace Startup finished in 2.051s (kernel) + 8.624s (initrd) + 7.408s (userspace) = 18.084s multi-user.target reached after 7.395s in userspace ============================================ This is what I did: --- /usr/lib/dracut/dracut-init.sh.old 2019-05-22 07:52:05.296000000 +0200 +++ /usr/lib/dracut/dracut-init.sh 2019-05-22 07:56:21.600000000 +0200 @@ -903,6 +903,10 @@ inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ret=$? + if [ "${1##*.ko}" = ".xz" ]; then + dinfo "unxz ${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" + unxz -f "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" + fi [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && \ [[ -d "$DRACUT_KERNEL_LAZY_HASHDIR" ]] && \ echo $ret > "$DRACUT_KERNEL_LAZY_HASHDIR/${1##*/}" FWIW Fedora already compresses modules, but they do it in their .spec file, not by the kernel config option: =============== kernel.spec =============== %ifarch %{ix86} x86_64 %global signkernel 1 %global signmodules 1 %global zipmodules 1 %else %global signkernel 0 %global signmodules 1 %global zipmodules 1 %endif ... if [ "%{zipmodules}" -eq "1" ]; then \ find $RPM_BUILD_ROOT/lib/modules/ -type f -name '*.ko' | xargs xz; \ fi \ =============== EOF =============== I am not sure why as Makefiles seem to do the right job: =============== Makefile =============== # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed # after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP # or CONFIG_MODULE_COMPRESS_XZ. mod_compress_cmd = true ifdef CONFIG_MODULE_COMPRESS ifdef CONFIG_MODULE_COMPRESS_GZIP mod_compress_cmd = gzip -n -f endif # CONFIG_MODULE_COMPRESS_GZIP ifdef CONFIG_MODULE_COMPRESS_XZ mod_compress_cmd = xz -f endif # CONFIG_MODULE_COMPRESS_XZ endif # CONFIG_MODULE_COMPRESS export mod_compress_cmd =============== scripts/Makefile.modinst =============== quiet_cmd_modules_install = INSTALL $@ cmd_modules_install = \ mkdir -p $(2) ; \ cp $@ $(2) ; \ $(mod_strip_cmd) $(2)/$(notdir $@) ; \ $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD)) ; \ $(mod_compress_cmd) $(2)/$(notdir $@)