From patchwork Fri Apr 9 13:28:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tor Vic X-Patchwork-Id: 12194165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29E86C433ED for ; Fri, 9 Apr 2021 13:28:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0142A610A4 for ; Fri, 9 Apr 2021 13:28:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbhDIN2o (ORCPT ); Fri, 9 Apr 2021 09:28:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbhDIN2o (ORCPT ); Fri, 9 Apr 2021 09:28:44 -0400 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F873C061760; Fri, 9 Apr 2021 06:28:31 -0700 (PDT) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4FGzV321Q0zQk1b; Fri, 9 Apr 2021 15:28:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-transfer-encoding:content-type:content-type:mime-version :subject:subject:message-id:from:from:date:date:received; s= mail20150812; t=1617974904; bh=AgkOpgV5Fc2cPWeeeC5cK0+Ypi2yAhdE9 Uac+kPGrzc=; b=T4Wu/bNnhNYsUOtcgSJazMb/y5I1b3Ce96kTU+gsw2tlvKY1U C7oT7eNe2TNkY+85Y5AChoS6usxJ8vqJvElp4G7zZe0VZOYbOfKt+loAUvUZM4Cn 5sMwGKrK1F8cwxwd7POln/DEeeOhAwR9CD5G1RjSsVVMpRuDAoo1YhuroQoMPCIP 0tuDlp+cNgrJy3CBtbBOI0YgwzoqO3ldFHWz5t42HDjrYOot5lxO5l7vuILdwh44 0Sf23ppWOM3ToO9xBDfBXQhQ7VM298zYwDDvyJTGouq1di2Vfnz3yw31pKXML7M5 mYrCqzMKLQDhrevE6qlMXH+Gk4VzoDWK0RzEw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1617974905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uUwqfRRZQovNuSAqVYPSHLzpotH8r/dvuT77yNbYt7Y=; b=ggnIJMrq8JeAkWx/XwKMp+hrYzFxFPAm5YpzqFEbHU7e7+HNyh6r5ub5ppVAS53I9WCI++ cpK3EMehBiWKktm5ZZSfkEUJVtQatPkD+MefXpWRt+099g3QTNxK2UFHmNfV6B2zdJg1WL R+H4RTkPJtTOqRgYtpjCheTSxCjZXSDwHokJeoJCyWtK5yQj08XEh9kUhkCfFFptsi4/ha woPIL0sU8Q4k0ncuR0d8NKZTNlF6QSChPP2Z48S3RSJ5hVs+C1DK1rck+I0Y2rytL4OfO+ fsOGADaZOZggD7Hb2CDt5Dcek8oROD+D/ZMebQOuL1VGVx6VL07Mv65M4FneaA== X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id RFvgcGJvakMQ; Fri, 9 Apr 2021 15:28:24 +0200 (CEST) Date: Fri, 9 Apr 2021 15:28:23 +0200 (CEST) From: torvic9@mailbox.org To: "linux-kbuild@vger.kernel.org" , "masahiroy@kernel.org" Cc: "linux-kernel@vger.kernel.org" , =?utf-8?q?Piotr_G=C3=B3rski?= Message-ID: <1557177615.69331.1617974903770@office.mailbox.org> Subject: [PATCH 1/2] kbuild: allow setting zstd compression level for modules MIME-Version: 1.0 X-Priority: 3 Importance: Normal X-MBO-SPAM-Probability: X-Rspamd-Score: -2.80 / 15.00 / 15.00 X-Rspamd-Queue-Id: 64A7117FA X-Rspamd-UID: 9b2d7a Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Zstd offers a very fine-grained control of compression ratios. Add a Kconfig option that allows setting the desired compression level for module compression. Based on Masahiro's linux-kbuild. Signed-off-by: Tor Vic Tested-by: Piotr Gorski --- init/Kconfig | 8 ++++++++ scripts/Makefile.modinst | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/init/Kconfig b/init/Kconfig index b5744d32c..15bb02c24 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2275,6 +2275,14 @@ config MODULE_COMPRESS_ZSTD endchoice +config MODULE_COMPRESS_ZSTD_LEVEL + int "Compression level (1-19)" + depends on MODULE_COMPRESS_ZSTD + range 1 19 + default 3 + help + Compression level used by zstd for compressing modules. + config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS bool "Allow loading of modules with missing namespace imports" help diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index ff9b09e4c..0a0db2278 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -97,7 +97,7 @@ quiet_cmd_gzip = GZIP $@ quiet_cmd_xz = XZ $@ cmd_xz = $(XZ) --lzma2=dict=2MiB -f $< quiet_cmd_zstd = ZSTD $@ - cmd_zstd = $(ZSTD) -T0 --rm -f -q $< + cmd_zstd = $(ZSTD) -$(CONFIG_MODULE_COMPRESS_ZSTD_LEVEL) -T0 --rm -f -q $< $(dst)/%.ko.gz: $(dst)/%.ko FORCE $(call cmd,gzip) From patchwork Fri Apr 9 13:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tor Vic X-Patchwork-Id: 12194167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CF71C433ED for ; Fri, 9 Apr 2021 13:31:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21C1361108 for ; Fri, 9 Apr 2021 13:31:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231756AbhDINb0 (ORCPT ); Fri, 9 Apr 2021 09:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231599AbhDINb0 (ORCPT ); Fri, 9 Apr 2021 09:31:26 -0400 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [IPv6:2001:67c:2050::465:103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64ED8C061761; Fri, 9 Apr 2021 06:31:13 -0700 (PDT) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4FGzYC47VgzQjx3; Fri, 9 Apr 2021 15:31:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mailbox.org; h= content-transfer-encoding:content-type:content-type:mime-version :subject:subject:references:in-reply-to:message-id:from:from :date:date:received; s=mail20150812; t=1617975065; bh=PpPDzBaifE tkZlonBqPbEjzUn9F7Q+H3PT2vmw7Iq6g=; b=pXEdTHuVxVuIm3izAYfatWmUPb aLszVGub/YPRwnVpX6uc6xierFdDd2llm74OTw6P2P7lylaCfGfATbN/AMpRMyH0 HadnWiSdlT+ARvAHkqi4PJ5mc+AzIrejCqZoij4RtlFQUuYbxH1VTDeblXXAPNqF z2hrN9qgdB77g5El2viQFJX5RfjaT88Q11tujW9a5inuRJ/W6Pn+ajkNXaDxJmCV zLnCifCt25p035P65JlzFi5lcDN+p4LL6ehvuPMMpTflqYk31LS+IazOEYKhK+Wh LCWTmSnFJ/+XhJexnXLT/L+Ydsrumkibl9wg6IjOcGYV9ZfKcOOLBb3TjHmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1617975069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O760yRcwt7n2sx3necIavnUPiURJl6AJeR9OvM52rLk=; b=Zxue1oUlDfb31XU4iqR077EoGeFsFjtf4tU4eeJ/axI+NkE621XNUiTbO7gMewHcKXWtFO mmCr8q8JHnTUE3qCN3dfZ2ZRksL7hfNCqpeS/63Xyi+0797dKXvOcN6VNN11yAG0jAhxg+ B7nZ4VmmcfL3Pg3IJtLHWUp7q5E80xjfcwdobs/2nMxubyJvxVYNdkfKj6RFXxJWlC1uui nBK6ryjoxVjK3tm3Z/q8u7IlsLTCgLLLQRSNaMTZK350zJO1ZdI+5APZqdeqUCUptr2V8O F/pUOvz2pwmDLHkQD28BX7dNotJIdyCww/5yD86litUr1saj8O1QfrYZiaYzCQ== X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id uBq6-GA7m_3V; Fri, 9 Apr 2021 15:31:05 +0200 (CEST) Date: Fri, 9 Apr 2021 15:31:05 +0200 (CEST) From: torvic9@mailbox.org To: "linux-kbuild@vger.kernel.org" , "masahiroy@kernel.org" Cc: "linux-kernel@vger.kernel.org" , =?utf-8?q?Piotr_G=C3=B3rski?= Message-ID: <1637052983.69379.1617975065141@office.mailbox.org> In-Reply-To: <1557177615.69331.1617974903770@office.mailbox.org> References: <1557177615.69331.1617974903770@office.mailbox.org> Subject: [PATCH 2/2] kbuild: allow setting zstd compression level for kernel MIME-Version: 1.0 X-Priority: 3 Importance: Normal X-MBO-SPAM-Probability: X-Rspamd-Score: -2.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: A99C1186A X-Rspamd-UID: 2aadda Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.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 --- 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 # ---------------------------------------------------------------------------