Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4340645rwb; Tue, 8 Nov 2022 15:55:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+7eM+EzYELkqR05a5uUlkh1JPpiYqs7dtMRWuFVl4DcJZ8vgS+h/oE9F8sFLQlWbVXPIB X-Received: by 2002:a17:902:f608:b0:188:758f:f45e with SMTP id n8-20020a170902f60800b00188758ff45emr641986plg.12.1667951725539; Tue, 08 Nov 2022 15:55:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667951725; cv=none; d=google.com; s=arc-20160816; b=abWzySRq71txfao4pY2OzWg8SiyHGrxlSodsjxjOTMq15ZdTjcXrkDFbNFENwVuteu i6gCiYD/x5E+EplxOW8AjOy4LcTpeVBZ0o6ByK0oEy9AJswDoXTub7GbZnKEKGuzr6fm DNNf7x/MlW9++4gbdC6tUAiaijvwnUWBFmcMeKu4AervriiMKbFa8Qy1gIOs2KwjNUqH 3v12MvwE8l/sqIC0zmUObwAbJMJ7k5p91NMtnGxwy02gL/VFLquM9heAIurtluShrkLB 1nGfHnThjCpBCP/cs19l8gOuxeeM4XiWFO3+3ZSAU3E+7CD9xXky9glFN6309nXRZ4Z4 4mlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:dkim-signature; bh=lL3wYywZqc8SuvAFtYvCg1Ig5Cr4m9aNe9NOfgkonxI=; b=J8AStrKK+0RT3j6DlVSUGs8RYJKpXqHtqZlCeyKentq3UinSST7wnp9MMfInahFJoo AID1N3gWVPxwPQ1lHkvamfoJ7zbOOxWPThuovV6M8wnQXxDmN5DKcErLMAlHT4ZVLJzZ ni9LgnLl30LvXiKoZeeFkaY0dSL7Q1TNbSdhEhlAZDN44YoIxbZ+/8bv7aXxkomf2O/q xzgxd5RnlmSiVuaePhfFNK8ng+uPX3gcJDfwnuxnMo1CJ4A1oWK6zBnGYJXTpH0L90rU S2jJ1P0/JqYXE4q2ffOZQe7Q/qtRUFw4q4KcjEVt4/0/bjP78jZuKnkZmsjoJQhMfGmv X2IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="MNU1xEk/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z29-20020a630a5d000000b0046b121a3246si15452701pgk.842.2022.11.08.15.55.13; Tue, 08 Nov 2022 15:55:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="MNU1xEk/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbiKHXl4 (ORCPT + 92 others); Tue, 8 Nov 2022 18:41:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbiKHXly (ORCPT ); Tue, 8 Nov 2022 18:41:54 -0500 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CE9356558; Tue, 8 Nov 2022 15:41:53 -0800 (PST) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-13b103a3e5dso18016530fac.2; Tue, 08 Nov 2022 15:41:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lL3wYywZqc8SuvAFtYvCg1Ig5Cr4m9aNe9NOfgkonxI=; b=MNU1xEk/jTlvgL9qgx9YOZGbQ1CP2VTMIAZkacmErgm2hxR81tp6el35ZJgtfl5eOf Rt4my9MG42zIdR112nUQ+jU1w5ImH9Snq974f/B5+VS8AGr6oNarYNJmwnN4Joj0ClHS 5Mizw85n/Xr5WMKSGczySWa7Y8YP1gHOrUTnFJChzF+lQbMGwbPkXA50Atg1Sk4YwqY7 BP5aqleLVPYNEn+swgNsZfYwXeEvEH5KKfxHyKJ6nDZp32/eoFdqu2XNztEYsYmexVZ6 PqJrXyHicAtFNqhFF5oMDNLTH/ihTrqWA7Tm7lK4+SFr5kmTsf9X40ZXvzx6xJj4kRlM J1oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lL3wYywZqc8SuvAFtYvCg1Ig5Cr4m9aNe9NOfgkonxI=; b=nZujN+BstE9sTtrmb768oOsds5TXN8O2UQ27GhrlWJ7BJiVJtqz88Ur5IHK9RKxMjQ UQIFw9KlqcR3ILLmQGzFHMwzE8crbv+VKpSafjgeA0mSQ5IcFynRlY2tis6jPAv+WVGH jvxfBV0VOlDMwTfkVBcIUpYsAtffZQwuHHU3MMqYJzcZCi+42rWWrF4w4SN0PyGPtHEj ISoWAMXeFbIK+peTHxkM3+zj3pcKlJE0nZAnnkBml+m6LQg+7VS37eotQSKU6TZt89oP 9vQVWBduPURsJiVDJtdnl/O0WogazX7JZnySFIEGMQKrIuObVMmr+xBpKc7SIDEznXcs IbiA== X-Gm-Message-State: ACrzQf1gdGzmjZkOVwtHCtyqd7DMewbqrio1Weq2ck62GmKtNbODE7/Q AebhY+wvghDIzAqeb6kVK/+wIgvjABvHpY770No= X-Received: by 2002:a05:6870:171d:b0:13d:173c:e71d with SMTP id h29-20020a056870171d00b0013d173ce71dmr28511421oae.252.1667950912446; Tue, 08 Nov 2022 15:41:52 -0800 (PST) MIME-Version: 1.0 References: <20221107180137.3634978-1-ndesaulniers@google.com> In-Reply-To: <20221107180137.3634978-1-ndesaulniers@google.com> Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Wed, 9 Nov 2022 00:41:15 +0100 Message-ID: Subject: Re: [PATCH v2] Makefile.debug: support for -gz=zstd To: Nick Desaulniers Cc: Masahiro Yamada , Fangrui Song , Sedat Dilek , Nathan Chancellor , Michal Marek , Nick Terrell , Tom Rix , Andrew Morton , "Peter Zijlstra (Intel)" , Kees Cook , Josh Poimboeuf , Dan Williams , Miguel Ojeda , Isabella Basso , Vlastimil Babka , Rasmus Villemoes , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 7, 2022 at 7:08 PM Nick Desaulniers wrote: > > Make DEBUG_INFO_COMPRESSED a choice; DEBUG_INFO_UNCOMPRESSED is the > default, DEBUG_INFO_COMPRESSED uses zlib, DEBUG_INFO_COMPRESSED_ZSTD > uses zstd. > > Some quick N=1 measurements with du, /usr/bin/time -v, and bloaty: > > clang-16, x86_64 defconfig plus > CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_UNCOMPRESSED=y: > Elapsed (wall clock) time (h:mm:ss or m:ss): 0:55.43 > 488M vmlinux > 27.6% 136Mi 0.0% 0 .debug_info > 6.1% 30.2Mi 0.0% 0 .debug_str_offsets > 3.5% 17.2Mi 0.0% 0 .debug_line > 3.3% 16.3Mi 0.0% 0 .debug_loclists > 0.9% 4.62Mi 0.0% 0 .debug_str > > clang-16, x86_64 defconfig plus > CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_COMPRESSED=y (zlib): > Elapsed (wall clock) time (h:mm:ss or m:ss): 1:00.35 > 385M vmlinux > 21.8% 85.4Mi 0.0% 0 .debug_info > 2.1% 8.26Mi 0.0% 0 .debug_str_offsets > 2.1% 8.24Mi 0.0% 0 .debug_loclists > 1.9% 7.48Mi 0.0% 0 .debug_line > 0.5% 1.94Mi 0.0% 0 .debug_str > > clang-16, x86_64 defconfig plus > CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_COMPRESSED_ZSTD=y (zstd): > Elapsed (wall clock) time (h:mm:ss or m:ss): 0:59.69 > 373M vmlinux > 21.4% 81.4Mi 0.0% 0 .debug_info > 2.3% 8.85Mi 0.0% 0 .debug_loclists > 1.5% 5.71Mi 0.0% 0 .debug_line > 0.5% 1.95Mi 0.0% 0 .debug_str_offsets > 0.4% 1.62Mi 0.0% 0 .debug_str > > That's only a 3.11% overall binary size savings over zlib, but at no > performance regression. > > This renames the existing KConfig options: > * DEBUG_INFO_UNCOMPRESSED -> DEBUG_INFO_COMPRESSED_NONE > * DEBUG_INFO_COMPRESSED -> DEBUG_INFO_COMPRESSED_ZLIB > So users upgrading may need to reset the new Kconfigs. > > Link: https://maskray.me/blog/2022-09-09-zstd-compressed-debug-sections > Link: https://maskray.me/blog/2022-01-23-compressed-debug-sections > Suggested-by: Sedat Dilek (DHL Supply Chain) > Reviewed-by: Nathan Chancellor > Signed-off-by: Nick Desaulniers > --- > Changes v1 -> v2: > * Remove `depends on DEBUG_KERNEL` as per Nathan. > * Rename Kconfigs as per Sedat and Masahiro. > * Add note about renamed Kconfigs to commit message. > * Add more help text to DEBUG_INFO_COMPRESSED_ZSTD. > > lib/Kconfig.debug | 29 +++++++++++++++++++++++++++-- > scripts/Makefile.debug | 4 ++++ > 2 files changed, 31 insertions(+), 2 deletions(-) > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index 29280072dc0e..7c28a8fba02e 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -312,8 +312,21 @@ config DEBUG_INFO_REDUCED > DEBUG_INFO build and compile times are reduced too. > Only works with newer gcc versions. > > -config DEBUG_INFO_COMPRESSED > - bool "Compressed debugging information" > +choice > + prompt "Compressed Debug information" > + help > + Compress the resulting debug info. Results in smaller debug info sections, > + but requires that consumers are able to decompress the results. > + > + If unsure, choose DEBUG_INFO_COMPRESSED_NONE. > + > +config DEBUG_INFO_COMPRESSED_NONE > + bool "Don't compress debug information" > + help > + Don't compress debug info sections. > + > +config DEBUG_INFO_COMPRESSED_ZLIB > + bool "Compress debugging information with zlib" > depends on $(cc-option,-gz=zlib) > depends on $(ld-option,--compress-debug-sections=zlib) > help > @@ -327,6 +340,18 @@ config DEBUG_INFO_COMPRESSED > preferable to setting $KDEB_COMPRESS to "none" which would be even > larger. > > +config DEBUG_INFO_COMPRESSED_ZSTD > + bool "Compress debugging information with zstd" > + depends on $(cc-option,-gz=zstd) > + depends on $(ld-option,--compress-debug-sections=zstd) > + help > + Compress the debug information using zstd. This may provide better > + compression than zlib, for about the same time costs, but requires newer > + toolchain support. Requires GCC 13.0+ or Clang 16.0+, binutils 2.40+, and > + zstd. > + > +endchoice # "Compressed Debug information" > + > config DEBUG_INFO_SPLIT > bool "Produce split debuginfo in .dwo files" > depends on $(cc-option,-gsplit-dwarf) > diff --git a/scripts/Makefile.debug b/scripts/Makefile.debug > index 332c486f705f..8ac3379d2255 100644 > --- a/scripts/Makefile.debug > +++ b/scripts/Makefile.debug > @@ -31,6 +31,10 @@ ifdef CONFIG_DEBUG_INFO_COMPRESSED ^^ ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZLIB ...from a quick (re)view. -Sedat- > DEBUG_CFLAGS += -gz=zlib > KBUILD_AFLAGS += -gz=zlib > KBUILD_LDFLAGS += --compress-debug-sections=zlib > +else ifdef CONFIG_DEBUG_INFO_COMPRESSED_ZSTD > +DEBUG_CFLAGS += -gz=zstd > +KBUILD_AFLAGS += -gz=zstd > +KBUILD_LDFLAGS += --compress-debug-sections=zstd > endif > > KBUILD_CFLAGS += $(DEBUG_CFLAGS) > > base-commit: f0c4d9fc9cc9462659728d168387191387e903cc > -- > 2.38.1.431.g37b22c650d-goog >