Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp482976pxb; Wed, 24 Feb 2021 07:16:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVBGrCIoKZC4YdLR7cDnrPga/ARHvVz9fWx+Aib5KsFAMjuUSYq/dmJQwSrbWKby4JRHXY X-Received: by 2002:a17:907:9802:: with SMTP id ji2mr11524096ejc.134.1614179812004; Wed, 24 Feb 2021 07:16:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614179811; cv=none; d=google.com; s=arc-20160816; b=pL+uq4SCnJnA5MMVB9salCkpJXIcbCLWJfFGCAGqCC57swbov4UMT2rqb6CU3+xDt6 SKuI6s/ukE3OyUiv1uuJgOc7IuJVtyakiBt+7hjPPWD2gn+f0Dr1Ek5WjG4UKVfQc6Tx pCBqmryF/nT2PqPr9fTO6W7OK5q4K0jL63E/aPdD856f7qw5xzC3ZymnQSADE3XwbIsT yb+3YaV5BiHOuwtly81oQ2iSpD9TFxtB0z0fLHdqaXBMtbXOKTf8KtPcrW1/R30dQeLH shXxUtaQK/7z5TJZc8GOxmFsRQG4FYA0rfUe/Nx8RcrIJ3m37Il0MhhG2cHx7tUOZaYs 7muA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=X4zuv4d96tdMkximP/nbEkrDkd3IdLGUhz6S9w9bT5o=; b=xndeagUcdN/xHBEFlDNfO3bPpk3ndSp1ZxRzCRRfD2uP/erVTexJXUvKQxjxxaBtNY aWwybyYiZVsWJEdxV4mgW5FC8TR4XOyk4U9+ZYPNQzfejFzFligesOyp4a0JVzSY1ai2 dCrQkgUCBEg/hu/oiOqmpXhIbYTCVAtljgMF1iX0CrR8/CvMw6qy3JBtUEqaezoWWfyW Rb0j8IM4f0B2A+/u2pyhtaaXGxXtHaLbSx1Ep+qMNDq3SlnTYL/mS4JypV697Bsg2t/Q 1GRaBWUBte5tq4c/G4sc1krbOR1bzclyUF7mhy5IGDY5qTN6zRfLX4YV4rNk92abdIHI 5MoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VPnVUBJd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si1468870ejs.165.2021.02.24.07.16.00; Wed, 24 Feb 2021 07:16:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VPnVUBJd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233398AbhBXPHJ (ORCPT + 99 others); Wed, 24 Feb 2021 10:07:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:50552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235882AbhBXOOc (ORCPT ); Wed, 24 Feb 2021 09:14:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68DA064E6B; Wed, 24 Feb 2021 14:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614176031; bh=VyP3xcVVsxiIDvrvtowoCWywy5tp49rAvYkYC6TXFPs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VPnVUBJdz+ChcPWRQglkQM3FdKMBLwQm+UHPr6lH8DUc6BYS9z61TVees47Z1Ss5j sYu9N1p8MH2p59Bh7pFY4utUYrchubFeqDEoukYvPyWDceBuqKU07XTJ3RnF4tQ6K1 8zHMVeyjp083A6sx46z1UkIokCSEF2jI8N1sZ0Vf2gSM8nAbHCky5+ODW55aNq4Dgq IO0hLly2DlvIXqLSWdqWHqr6AWN0N1LLPLN3CMX19vtz8U9VCDwVsNTpSFeYAeP5Nz 7ieWU4WteB26MqsDUUsIewlWwRWJqXIXVYWaJfM39nCShgszDl94fDCZmyiniVLooL AfjQtSYtk3L5A== Date: Wed, 24 Feb 2021 15:13:44 +0100 From: Jessica Yu To: Christoph Hellwig Cc: Linus Torvalds , Linux Kernel Mailing List , =?utf-8?B?77+8TWlyb3NsYXY=?= Benes , Emil Velikov , Masahiro Yamada Subject: Re: [GIT PULL] Modules updates for v5.12 Message-ID: References: <20210223200130.GA8059@lst.de> <20210224075220.GA546@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210224075220.GA546@lst.de> X-OS: Linux gunter 5.11.0-rc4-1-default+ x86_64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Christoph Hellwig [24/02/21 08:52 +0100]: >On Tue, Feb 23, 2021 at 12:07:39PM -0800, Linus Torvalds wrote: >> On Tue, Feb 23, 2021 at 12:03 PM Linus Torvalds >> wrote: >> > >> > This is unacceptably slow. If that symbol trimming takes 30% of the >> > whole kernel build time, it needs to be fixed or removed. >> >> I think I'm going to mark TRIM_UNUSED_KSYMS as "depends on BROKEN". >> There's no way I can accept that horrible overhead, and the rationale >> for that config option is questionable at best, > >I think it is pretty useful for embedded setups. > >BROKEN seems pretty strong for something that absolutely works as >intendended. I guess to make you (and possibly others) not grumpy >we just need to ensure it doesn't get pulled in by allmodconfig. > >So maybe just invert the symbol, default the KEEP_UNUSED_SYMBOL, and >add a message to the helptext explaining the slowdown? Hm, something like this maybe? (untested) --- From 08bc08229fc3801b1a580a07ce7ff3e806b3fe90 Mon Sep 17 00:00:00 2001 From: Jessica Yu Date: Wed, 24 Feb 2021 14:54:09 +0100 Subject: [PATCH] Kconfig: invert TRIM_UNUSED_SYMBOLS option and rename it to KEEP_UNUSED_SYMBOLS Removing CONFIG_UNUSED_SYMBOLS (commit 367948220fce "module: remove EXPORT_UNUSED_SYMBOL*") unhid the CONFIG_TRIM_UNUSED_SYMBOLS option and therefore it now gets automatically enabled with allyesconfig. To prevent allyesconfig from enabling TRIM_UNUSED_SYMBOLS (which is known to slow build times), invert the config option and name it KEEP_UNUSED_SYMBOLS, which does the same thing as TRIM_UNUSED_SYMBOLS=n. That way, allyesconfig will keep the previous behavior of not trimming symbols. Signed-off-by: Jessica Yu --- Makefile | 4 ++-- arch/mips/configs/generic_defconfig | 2 +- include/asm-generic/export.h | 2 +- include/linux/export.h | 2 +- init/Kconfig | 21 +++++++++++---------- kernel/livepatch/Kconfig | 2 +- scripts/Makefile.build | 2 +- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index b18dbc634690..23f50521e97f 100644 --- a/Makefile +++ b/Makefile @@ -1164,7 +1164,7 @@ vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) # Recurse until adjust_autoksyms.sh is satisfied PHONY += autoksyms_recursive -ifdef CONFIG_TRIM_UNUSED_KSYMS +ifndef CONFIG_KEEP_UNUSED_KSYMS # For the kernel to actually contain only the needed exported symbols, # we have to build modules as well to determine what those symbols are. # (this can be evaluated only once include/config/auto.conf has been included) @@ -1175,7 +1175,7 @@ autoksyms_recursive: descend modules.order "$(MAKE) -f $(srctree)/Makefile vmlinux" endif -autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h) +autoksyms_h := $(if $(CONFIG_KEEP_UNUSED_KSYMS),,include/generated/autoksyms.h) quiet_cmd_autoksyms_h = GEN $@ cmd_autoksyms_h = mkdir -p $(dir $@); \ diff --git a/arch/mips/configs/generic_defconfig b/arch/mips/configs/generic_defconfig index 714169e411cf..d46da28ea032 100644 --- a/arch/mips/configs/generic_defconfig +++ b/arch/mips/configs/generic_defconfig @@ -29,7 +29,7 @@ CONFIG_MIPS_O32_FP64_SUPPORT=y CONFIG_JUMP_LABEL=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y -CONFIG_TRIM_UNUSED_KSYMS=y +CONFIG_KEEP_UNUSED_KSYMS=n CONFIG_NET=y CONFIG_PACKET=y CONFIG_UNIX=y diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 07a36a874dca..06d401464195 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -57,7 +57,7 @@ __kstrtab_\name: #endif .endm -#if defined(CONFIG_TRIM_UNUSED_KSYMS) +#if !defined(CONFIG_KEEP_UNUSED_KSYMS) #include #include diff --git a/include/linux/export.h b/include/linux/export.h index 6271a5d9c988..449f7d15e580 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -118,7 +118,7 @@ struct kernel_symbol { */ #define __EXPORT_SYMBOL(sym, sec, ns) -#elif defined(CONFIG_TRIM_UNUSED_KSYMS) +#elif !defined(CONFIG_KEEP_UNUSED_KSYMS) #include diff --git a/init/Kconfig b/init/Kconfig index ba8bd5256980..db5d00bfc239 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2272,29 +2272,30 @@ config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS If unsure, say N. -config TRIM_UNUSED_KSYMS - bool "Trim unused exported kernel symbols" - depends on BROKEN +config KEEP_UNUSED_KSYMS + bool "Keep unused exported kernel symbols" + default y help The kernel and some modules make many symbols available for other modules to use via EXPORT_SYMBOL() and variants. Depending on the set of modules being selected in your kernel configuration, many of those exported symbols might never be used. - This option allows for unused exported symbols to be dropped from - the build. In turn, this provides the compiler more opportunities - (especially when using LTO) for optimizing the code and reducing - binary size. This might have some security advantages as well. + This option allows for unused exported symbols to be kept in the + build. Say N when you want to trim unused symbols from the build, + which provides the compiler more opportunities (especially when using LTO) + for optimizing the code and reducing binary size. This might have some + security advantages as well. - If unsure, or if you need to build out-of-tree modules, say N. + If unsure, or if you need to build out-of-tree modules, say Y. config UNUSED_KSYMS_WHITELIST string "Whitelist of symbols to keep in ksymtab" - depends on TRIM_UNUSED_KSYMS + depends on !KEEP_UNUSED_KSYMS default "scripts/lto-used-symbollist.txt" if LTO_CLANG help By default, all unused exported symbols will be un-exported from the - build when TRIM_UNUSED_KSYMS is selected. + build when KEEP_UNUSED_KSYMS is not selected. UNUSED_KSYMS_WHITELIST allows to whitelist symbols that must be kept exported at all times, even in absence of in-tree users. The value to diff --git a/kernel/livepatch/Kconfig b/kernel/livepatch/Kconfig index 53d51ed619a3..df8ebb7984e1 100644 --- a/kernel/livepatch/Kconfig +++ b/kernel/livepatch/Kconfig @@ -11,7 +11,7 @@ config LIVEPATCH depends on SYSFS depends on KALLSYMS_ALL depends on HAVE_LIVEPATCH - depends on !TRIM_UNUSED_KSYMS + depends on KEEP_UNUSED_KSYMS help Say Y here if you want to support kernel live patching. This option has no runtime impact until a kernel "patch" diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 3f6bf0ea7c0e..e5e95a6948a7 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -242,7 +242,7 @@ objtool_dep = $(objtool_obj) \ $(wildcard include/config/orc/unwinder.h \ include/config/stack/validation.h) -ifdef CONFIG_TRIM_UNUSED_KSYMS +ifndef CONFIG_KEEP_UNUSED_KSYMS cmd_gen_ksymdeps = \ $(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd