All of lore.kernel.org
 help / color / mirror / Atom feed
From: torvic9@mailbox.org
To: "linux-kbuild@vger.kernel.org" <linux-kbuild@vger.kernel.org>,
	"masahiroy@kernel.org" <masahiroy@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Piotr Górski" <lucjan.lucjanov@gmail.com>
Subject: [PATCH 2/2] kbuild: allow setting zstd compression level for kernel
Date: Fri, 9 Apr 2021 15:31:05 +0200 (CEST)	[thread overview]
Message-ID: <1637052983.69379.1617975065141@office.mailbox.org> (raw)
In-Reply-To: <1557177615.69331.1617974903770@office.mailbox.org>

In a similar way to the first patch in this series, add another Kconfig
option that allows setting the zstd compression level for the kernel
as well.
This enables users to choose either a compression level between 1 and 19,
or instead use the highest possible level (ultra-22).
Also add '-T0' parameter in both cases.

Signed-off-by: Tor Vic <torvic9@mailbox.org>
---
 arch/x86/boot/compressed/Makefile |  5 +++++
 init/Kconfig                      | 19 +++++++++++++++++++
 scripts/Makefile.lib              |  4 ++--
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index e0bc3988c..59ed10c61 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -130,8 +130,13 @@ $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE
 	$(call if_changed,lzo)
 $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
 	$(call if_changed,lz4)
+ifdef CONFIG_KERNEL_ZSTD_ULTRA
 $(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE
 	$(call if_changed,zstd22)
+else
+$(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE
+	$(call if_changed,zstd)
+endif
 
 suffix-$(CONFIG_KERNEL_GZIP)	:= gz
 suffix-$(CONFIG_KERNEL_BZIP2)	:= bz2
diff --git a/init/Kconfig b/init/Kconfig
index 15bb02c24..1d3c5eebf 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -321,6 +321,25 @@ config KERNEL_UNCOMPRESSED
 
 endchoice
 
+menu "ZSTD compression options"
+    depends on KERNEL_ZSTD
+
+config KERNEL_ZSTD_LEVEL
+    int "Compression level (1-19)"
+    range 1 19
+    default 19
+    help
+        Choose a compression level for zstd kernel compression.
+        Default is 19.
+
+config KERNEL_ZSTD_LEVEL_ULTRA
+    bool "Ultra compression"
+    help
+        Selecting this overrides the chosen compression level and enables
+        the highest possible compression level for zstd (ultra-22).
+
+endmenu
+
 config DEFAULT_INIT
 	string "Default init path"
 	default ""
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a4fbaf888..aa29b97fb 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -455,10 +455,10 @@ quiet_cmd_xzmisc = XZMISC  $@
 # be used because it would require zstd to allocate a 128 MB buffer.
 
 quiet_cmd_zstd = ZSTD    $@
-      cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@
+      cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -$(CONFIG_KERNEL_ZSTD_LEVEL) -T0; $(size_append); } > $@
 
 quiet_cmd_zstd22 = ZSTD22  $@
-      cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@
+      cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra -T0; $(size_append); } > $@
 
 # ASM offsets
 # ---------------------------------------------------------------------------
-- 
2.31.1

      reply	other threads:[~2021-04-09 13:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 13:28 [PATCH 1/2] kbuild: allow setting zstd compression level for modules torvic9
2021-04-09 13:31 ` torvic9 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1637052983.69379.1617975065141@office.mailbox.org \
    --to=torvic9@mailbox.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucjan.lucjanov@gmail.com \
    --cc=masahiroy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.