From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32337328628; Wed, 7 Jan 2026 12:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767788637; cv=none; b=HpH2IziFUJykzjK/UR+GW6lHgN81inP3Wl5ud9JQsTTyTvVua+b5+lbpYxYhKCq8FyP5ud6Hd733h2TOqeuiZo0EAxF6LK+5rVAYtQcP0Dbl/g9dhiIkidJrxNQIps0UmKUGIV3mPPrfr1stl4g2ff3/DCqObOiX9Yc4KcLpT+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767788637; c=relaxed/simple; bh=mZtM1KRXrNZPIjs0BP4nXfJn9/N+qtrTbb5tiAYIPzg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=oPpXQRZWQPxcr0R4JGTvH5gWsQQ2P1gEd+wtjbSt2XhfTIU8T8YscKNy7NAJ+nC9WNdmpdNOXcTPDTXUn6S+ge0esBJTL4PNQsI6unpGZYxRLtt1uKuu4khiM0zU28SUkSORV43v2gVXWsbQWwh/Le1XQwbC1VC0LvLhlR3Bpzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jsilMsD9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jsilMsD9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0535EC16AAE; Wed, 7 Jan 2026 12:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767788637; bh=mZtM1KRXrNZPIjs0BP4nXfJn9/N+qtrTbb5tiAYIPzg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jsilMsD9MU5vYOo+CLDlCD4K1PG/wWHtloGE+yTehzPOpuQxbC4VkaA5SDbLGwG+8 NoGTAZRmkN3B/N39tcHxDRacYTzE26znGZWG6DK9P1a24yxnyGqNw0NGTEOhL1cCDn dVkYCJTcJdvV3AnC31ROUCNjK4WzEK0Rk0A3pfxYacTnTIJob6V5LNMiBdaFubd085 h58fmGlG/jR4aWt0H5ONm3dEZ3oYNYGVyM2DPPqpSr3sUsMbKs8GEZ9tdE6s4vMFND iGZ/LYsMAQDMLzqD2kCZmCnwKYXfvcW8VkBSm798XIEDL42GwbPYWgMt8mfXEV8FTI M5SK7HdQJxaaw== From: Andreas Hindborg To: Alice Ryhl , Miguel Ojeda Cc: Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , Benno Lossin , Trevor Gross , Danilo Krummrich , Alexandre Courbot , Will Deacon , Peter Zijlstra , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Nicolas Schier , Andrew Morton , Uladzislau Rezki , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-kbuild@vger.kernel.org, linux-mm@kvack.org, nouveau@lists.freedesktop.org, Alice Ryhl , Matthew Maurer Subject: Re: [PATCH 0/4] Inline helpers into Rust without full LTO In-Reply-To: <20251202-inline-helpers-v1-0-879dae33a66a@google.com> References: <20251202-inline-helpers-v1-0-879dae33a66a@google.com> Date: Wed, 07 Jan 2026 13:23:38 +0100 Message-ID: <87y0m9har9.fsf@t14s.mail-host-address-is-not-set> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Hi Alice, Alice Ryhl writes: > Currently the only way for Rust code to call a static inline function is > to go through a helper in rust/helpers/. This introduces performance > costs due to additional function calls and also clutters backtraces and > flame graphs with helper symbols. > > To get rid of these helper symbols, provide functionality to inline > helpers into Rust using llvm-link. This option complements full LTO, by > being much cheaper and avoiding incompatibility with BTF. > > I ran a microbenchmark showing the benefit of this. All the benchmark > does is call refcount_inc() in a loop. This was chosen since refcounting > is quite hot in Binder. The results are that Rust spends 6.35 ns per > call vs 5.73 ns per call in C. When enabling this option, the two > languages become equally fast, and disassembly confirms the exact same > machine code is used (in particular there is no call to > rust_helper_refcount_inc). Benchmarking Binder also results in an > improvement from this change. > > This patch is complementary to: > https://lore.kernel.org/all/20251202-define-rust-helper-v1-0-a2e13cbc17a6@google.com/ > > Signed-off-by: Alice Ryhl I get the following modpost errors when building with this applied on top of v6.19-rc4: ERROR: modpost: "__SCK__WARN_trap" [drivers/gpu/drm/nova/nova.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [drivers/gpu/nova-core/nova_core.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [drivers/block/rnull/rnull_mod.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_minimal.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_misc_device.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_print.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_dma.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_driver_pci.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_driver_platform.ko] undefined! ERROR: modpost: "__SCK__WARN_trap" [samples/rust/rust_driver_faux.ko] undefined! I also applied the series adding the inline macro [1]. Best regards, Andreas Hindborg [1] https://lore.kernel.org/rust-for-linux/20260105-define-rust-helper-v2-0-51da5f454a67@google.com/