gnu: linux-libre: Enable Zstd compression of kernel modules.

This brings the on disk size of the kernel from 164 MiB to 144 MiB, or about
12%.

* gnu/packages/linux.scm (default-extra-linux-options)
[version>=5.13]: Enable CONFIG_MODULE_COMPRESS_ZSTD, else
CONFIG_MODULE_COMPRESS_GZIP.
(make-linux-libre*) [phases] {set-environment}: Set ZSTD_CLEVEL environment
variable to 19.
[native-inputs]: Add zstd.
* gnu/build/linux-modules.scm (module-regex): Add .zst to regexp.  Update doc.
(modinfo-section-contents): Extend support to Zstd compressed module.
(dot-ko): Register the 'zstd compression type.
(ensure-dot-ko, file-name->module-name, load-linux-module*)
(module-name->file-name/guess, write-module-name-database)
(write-module-alias-database, write-module-device-database): Update doc.
(module-name-lookup): Also consider zstd-compressed modules.
* gnu/installer.scm (installer-program): Add guile-zstd extension to gexp.
* gnu/system/linux-initrd.scm (flat-linux-module-directory): Likewise.
Decompress zstd-compressed modules for use in initrd.
* guix/profiles.scm (linux-module-database): Add guile-zstd extension to gexp.

Change-Id: Ide899dc5c58ea5033583b1a91a92c025fc8d901a
This commit is contained in:
Maxim Cournoyer 2024-05-12 20:51:50 -04:00
parent b72b6063ce
commit afacfa33ec
No known key found for this signature in database
GPG key ID: 1260E46482E63562
5 changed files with 57 additions and 32 deletions

View file

@ -874,6 +874,10 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
,@(if (version>=? version "5.13")
'(("BPF_UNPRIV_DEFAULT_OFF" . #t))
'())
;; Compress kernel modules via Zstd.
,(if (version>=? version "5.13")
'("CONFIG_MODULE_COMPRESS_ZSTD" . #t)
'("CONFIG_MODULE_COMPRESS_GZIP" . #t))
;; Some very mild hardening.
("CONFIG_SECURITY_DMESG_RESTRICT" . #t)
;; All kernels should have NAMESPACES options enabled
@ -1063,7 +1067,10 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
"EXTRAVERSION ?="))
(setenv "EXTRAVERSION"
#$(and extra-version
(string-append "-" extra-version)))))
(string-append "-" extra-version)))
;; Use the maximum compression available for Zstd-compressed
;; modules.
(setenv "ZSTD_CLEVEL" "19")))
(replace 'configure
(lambda _
(let ((config
@ -1157,7 +1164,9 @@ ARCH and optionally VARIANT, or #f if there is no such configuration."
;; support.
dwarves ;for pahole
python-wrapper
zlib))
zlib
;; For Zstd compression of kernel modules.
zstd))
(home-page "https://www.gnu.org/software/linux-libre/")
(synopsis "100% free redistribution of a cleaned Linux kernel")
(description "GNU Linux-Libre is a free (as in freedom) variant of the