From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8CB3C88E72 for ; Thu, 17 Sep 2026 17:49:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ejcm17Jubs4wUZ3wiXj8nfxGGSE9e7zpmhxxA76ErUM=; b=U6igyoUTVasCOE ksLumXl8UdZ2cthSSXmY32/UD8qdHb9NSrzHzpcSXE2o5YKhqtgXNsgedzIca/F8PfMIFy3OQeM97 WM80GGc6CIez/kAQQjkNt0Y9f4YOd8ATN4+rcrn0OJb81ULC4Bko0nlgXrO47QYny0hW2GLxdR0IO OpuDArsu2bJwPuHPAl7axIzmubcZknRens8rw8Qz7Hpm7tjX57eBCqUIUqquYKsQfbv+Pa6RK2UJr Sns8N9eD4J74kgkF24UzS2vZKMYiMruhXbS0ryxzPdMP+VY7aGXFMgbloa8oCsJ+kMDShMiesb8b/ F/cPn/3haV53TozEBwmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x7GEH-0000000C80F-1shI; Thu, 17 Sep 2026 17:49:01 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x7GEF-0000000C7zz-1Ekz; Thu, 17 Sep 2026 17:48:59 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id F08624394A; Thu, 17 Sep 2026 17:48:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 532FE1F00893; Thu, 17 Sep 2026 17:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789667338; bh=cLEPRaYpBPlArN2n02K1AD2Rlu0XR0AJhYbLviaj3qM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=eD0v9cqdgBAUzVJbc7kjrlV3qCR0kIq2aRz9aYFnLytwcEsSYKq8AluHxvetYtYbi 7A6jDrDOhHLKiWdG/zGXUSUrGGkmq+2NIdJAoBC2vo5dyhN1GmVOMBkqW/TPCnu09T plevC+hdjuYu0ZTywktA34FPhUC0ZkyRHQilYNmJKdi01T+gMm7Twyn6vHwCwevFb6 DHdLJMHYPF08eGJb8lwsYjrxI+26lBYj0DabQZJg1vueFR/rhEtITeWNNSCYgkbGci pS1y+BJjp4iJElZdF0b2xnd9QHQ60hebn+u/fyQRTVmo1T8bOtLHQas6z1jrLhmj07 Iu0V34hWVATXA== Date: Thu, 17 Sep 2026 18:48:43 +0100 From: "Lorenzo Stoakes (ARM)" To: Kees Cook Cc: Linus Torvalds , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , Masahiro Yamada , Alexey Gladkov , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Arnd Bergmann , Catalin Marinas , Will Deacon , Mark Rutland , Ard Biesheuvel , Ilias Apalodimas , Josh Poimboeuf , Peter Zijlstra , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?utf-8?B?w5Z6a2Fu?= , Jonathan Corbet , Randy Dunlap , "Gustavo A. R. Silva" , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-doc@vger.kernel.org, Jens Axboe , linux-hardening@vger.kernel.org Subject: Re: [PATCH v3 05/20] kbuild: only emit vmlinux relocations when required Message-ID: References: <20260917-build-speedup-v3-0-9ecf4163ff36@kernel.org> <20260917-build-speedup-v3-5-9ecf4163ff36@kernel.org> <202609171039.A9B14A02A@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202609171039.A9B14A02A@keescook> X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Thu, Sep 17, 2026 at 10:41:50AM -0700, Kees Cook wrote: > On Thu, Sep 17, 2026 at 05:06:15PM +0100, Lorenzo Stoakes (ARM) wrote: > > A kernel build consists of more than one linking pass on vmlinux.o and > > vmlinux, at minimum two, and with CONFIG_KALLSYMS and BTF enabled on x86-64 > > for example there are 5 such stages. > > > > For architectures that build their own relocation tables (x86, riscv, mips, > > s390), vmlinux is linked with the --emit-relocs parameter specified. > > > > However, this is only required on the final vmlinux link. > > > > Symbol tables of trial links preceding it don't need it because they > > already check that System.map matches kallsyms symbols on each build. > > > > GNU ld is slow at emitting relocation tables, so this results in a > > reduction in build time. > > > > Whole build, 128-thread Threadripper 9980X, best of N runs: > > > > before after delta > > ------------------------------- > > x86 defconfig, touch mm/vma.c, gcc 9.5s 9.1s -0.42s (-4%) > > x86 defconfig, clean, gcc 30.1s 29.5s -0.59s (-2%) > > x86 allmodconfig, touch mm/vma.c, gcc 37.2s 35.8s -1.4s (-4%) > > > > Note that this has little impact on LLVM ld which performs this operation > > more efficiently. > > > > Assisted-by: LLM > > Signed-off-by: Lorenzo Stoakes (ARM) > > --- > > Makefile | 2 +- > > scripts/link-vmlinux.sh | 5 +++++ > > 2 files changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/Makefile b/Makefile > > index 0f1b80100b47..dd4c10afbb7f 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -1263,7 +1263,7 @@ LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL) > > endif > > > > ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),) > > -LDFLAGS_vmlinux += --emit-relocs --discard-none > > +LDFLAGS_vmlinux += --discard-none > > endif > > Nit: I think a comment here is worth adding, like in link-vmlinux.sh. > They're separate files, and it's kind of weird that ...NEEDS_RELOCS > doesn't actually add --emit-relocs here unless you go find how > --emit-relocs is used later. Ack will add! > > > > > # Align the architecture of userspace programs with the kernel > > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > > index 970ca10f8fa9..ed5ff97c0667 100755 > > --- a/scripts/link-vmlinux.sh > > +++ b/scripts/link-vmlinux.sh > > @@ -96,6 +96,11 @@ vmlinux_link() > > ldflags="${ldflags} ${wl}--strip-debug" > > fi > > > > + # Only the final link actually requires the relocations. > > + if [ "${output}" = "${VMLINUX}" ] && is_enabled CONFIG_ARCH_VMLINUX_NEEDS_RELOCS; then > > + ldflags="${ldflags} ${wl}--emit-relocs" > > + fi > > + > > if [ -n "${generate_map}" ]; then > > ldflags="${ldflags} ${wl}-Map=vmlinux.map" > > fi > > But yeah, otherwise, another "don't generate something that doesn't get > used" improvement. :) Yes :) it's funny how simple a lot of these changes are - Don't do work you don't need to - Cache stuff so you don't have to look it up again (a variant on the first one) - Do other work at the same time > > Reviewed-by: Kees Cook Thanks! > > -- > Kees Cook -- Cheers, Lorenzo _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv