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 E7E71C88E64 for ; Mon, 14 Sep 2026 09:25:05 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YKtXzFsgsXb0NzuybdwYVRrz0lPLfzjwt+EXyBU0r1U=; b=ZZAg2cJyH/izB+ hOTIy6nBJHT7NgO/HiqKGIZ4mGz6aG8hq48Z36kevg9P+h4eWUyGq4E9tKBd1uqbFuZWgeLpNkhnp zTgyg4TwA4vImJjwonKlUXzkJAJhvX6+FX6rxXD1nypi2wLSBkCF0hmeiqiaEtwRd5ogeuln4bdx7 fSp02yucBFS41DpMjd1Yqtc8rEojsEol5raN9obRzD2m+ibBswD4OSaXrEXvK2YGyTcw+85XXOS7Q szjMxtIeJlDFW4mKLZxlhgqR68G/4XshxrHueiBXXhJlEhV/PuB3Wx7MLx8WBq4MWvpVRNxiEoIac Rjl05rJzsGTLqY/k78sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x62vm-00000002vu2-3OEl; Mon, 14 Sep 2026 09:24:54 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x62vl-00000002vt6-0NU7; Mon, 14 Sep 2026 09:24:53 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 8664D60142; Mon, 14 Sep 2026 09:24:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26F3D1F00899; Mon, 14 Sep 2026 09:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789377892; bh=jMlk8ESG3VZosnVPda+JnxrYfeoPZS29Gj5h4KPFBVk=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=UB3C0Z5mPs8gzBFSkClKgPRe6YkPx+LN/6Ej67xkNnWJZS/RA732odZUOqE+c9F/D /auxIyF/OxkBAvo3QwtH+zFLWbEUPDwQU/kuKLyyfXD7b8mLIlfwNsmrFS04bSKBcM s9mbsEPeCUpkXjN9KonE2vhaRkMqKXnKFbRH+I/45HZxXNp4GcxLLFkweDHkoxBe0L N5tBxyIq5qSjT2h37GgI+8sA9fBDVN+6sSG0UOZhWuju7P5O751iq260OhYhPpQ9a0 99Dca7tQVF7OcRh/U/BR8Y/Dw2ID5OlFZom25Yuv8Q3KrunRrXuejfbHgBGPofkCi+ ju2qJcOyrcSrg== From: "Lorenzo Stoakes (ARM)" Date: Mon, 14 Sep 2026 10:22:17 +0100 Subject: [PATCH v2 18/21] kbuild: rust: optionally parallelise rustc front end MIME-Version: 1.0 Message-Id: <20260914-build-speedup-v2-18-39817ec5db23@kernel.org> References: <20260914-build-speedup-v2-0-39817ec5db23@kernel.org> In-Reply-To: <20260914-build-speedup-v2-0-39817ec5db23@kernel.org> To: 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?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= , Jonathan Corbet , Randy Dunlap , Kees Cook , "Gustavo A. R. Silva" Cc: 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, "Lorenzo Stoakes (ARM)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3400; i=ljs@kernel.org; h=from:subject:message-id; bh=9iG9qS6AGuVzz+DVqJCGQaA7fnTb/NXKN1FW+0AWki8=; b=owGbwMvMwCV2fu7ZrsZH9SKMp9WSGLKW7zm0x8Xkb6Fl9DRLeRHmlQ/Wn/BgiQ2Pq6jMiRDa+ jbn3L9vHaUsDGJcDLJiiizPv4jvDxIJm9d5wd8NZg4rE8gQBi5OAZjIsSSG/1kuxizKkQtqG1hz 4ypWuag5mDxO2MHU+JWNTbNfuW5WDyPDRRb7U5PW7zELVIgNP252qKX6rCPL1Of2ovlsFYmHfsz jBQA= X-Developer-Key: i=ljs@kernel.org; a=openpgp; fpr=E7F417BF5214569E89D04F46CF9DCD8A81E27F14 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 Rust crates are compiled in a serial chain on the critical path - core, bindings, kernel crates and then the drivers - each a rustc invocation. With CONFIG_RUST set and every rust driver enabled, the entire chain takes around 25 seconds on a 128-thread machine, with the associated C code taking 24 seconds. Each time a change is made to any of the bindings, it triggers a rebuild. rustc has a parallel front end, enabled with -Zthreads, available since rust 1.84 [0] and therefore on every rustc the kernel supports. It is not yet stable and its output is not reproducible, so it cannot be used by default - stabilisation is being worked on [1]. Add optional build parameter KBUILD_RUST_THREADS, which when set passes that many threads to rustc. The threads are taken from make's jobserver, so a parallel build is not oversubscribed. It was found that benefits level off at 8 threads (16 was found to be around the same, and 32 slower). Generated output was confirmed byte-for-byte identical. Observed build time changes with KBUILD_RUST_THREADS=8 (rustc 1.98, clang): before after core.o 7.7s 4.9s bindings.o 4.3s 3.1s kernel.o 2.0s 1.4s clean build 39.3s 34.6s touch rust/kernel/lib.rs 12.9s 12.1s touch rust/bindings/bindings_helper.h 19.5s 17.5s Whole build, 128-thread Threadripper 9980X, KBUILD_RUST_THREADS=8, best of N runs: before after delta ------------------------------- x86 defconfig+RUST, clean 41.0s 36.4s -4.6s (-11%) x86 defconfig+RUST, touch lib.rs 8.3s 7.7s -0.56s (-7%) Link: https://github.com/rust-lang/rust/pull/132282 [0] Link: https://github.com/rust-lang/compiler-team/issues/1005 [1] Assisted-by: LLM Signed-off-by: Lorenzo Stoakes (ARM) --- Documentation/kbuild/kbuild.rst | 7 +++++++ Makefile | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 5a9013bacfb7..9b2b127676c3 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -134,6 +134,13 @@ See make help for the full list. Setting "V=..." takes precedence over KBUILD_VERBOSE. +KBUILD_RUST_THREADS +------------------- +The number of threads rustc's parallel front end may use, passed to it as +``-Zthreads``. Unset by default, as the parallel front end is not yet +stable and its output is not reproducible. The gain levels off at 8 +threads. + KBUILD_EXTMOD ------------- Set the directory to look for the kernel source when building external diff --git a/Makefile b/Makefile index 8263fc8a86b3..4ef504c1ace2 100644 --- a/Makefile +++ b/Makefile @@ -1206,6 +1206,10 @@ KBUILD_RUSTFLAGS += --remap-path-prefix=$(srcroot)/= --remap-path-scope=macro endif endif +ifneq ($(KBUILD_RUST_THREADS),) +KBUILD_RUSTFLAGS += -Zthreads=$(KBUILD_RUST_THREADS) +endif + # include additional Makefiles when needed include-y := scripts/Makefile.warn include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug -- 2.55.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv