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 C54B9396596; Tue, 17 Mar 2026 08:26:00 +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=1773735960; cv=none; b=jlbglMPnlMH2dSQj8d4ZuWW50A2JYEntAeXl4bmOgVQmP1QiYYQ27gstkLbC2mfiX9G5Iv+oQHDcAj5SeVuk05Px9yyzX2IWVf00HPT9WYISStE0KsfdpLmIVKlF10Y6DaSiWGLWuK+bJK72HPBrwWixXvM0Ebsy4dn/WJBPjxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773735960; c=relaxed/simple; bh=6HCO5uPSGeOaMZcJw6nr0BVRKGBfSPMmN8QCDipCPTc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Zi7sSIiPCmEoCkb1N1Jn6AEqYC/W6lFQtKWf1HVCbJ2d0FYt5MXALLErEDeC06ImRK5GYGQvcIWLf24+g18uBMTtw+pb4L4T+MRlAQiqfbHgB9YMTRLznHLw2kv5iOuR1qjXFCwrHLGFKlVRjt86cMI5Cdk15jAyxagc84ZqDww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eUcG/RcM; 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="eUcG/RcM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B294C4CEF7; Tue, 17 Mar 2026 08:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773735960; bh=6HCO5uPSGeOaMZcJw6nr0BVRKGBfSPMmN8QCDipCPTc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eUcG/RcMZtaj14Gihl0G/ahNqH+BeBeIakaQmbDtYO95yN5aBqlhS17SCZzXnqzSK tt4jainE8Ae1JjEz4Bx8Txdi21R2Cxvbv4UFiCLGf7S/Ii3s130y0a+ef53ttNF6j8 oyWVVSe++PFiYUTROTpRvwUfy/XNQ8hxvxAl+Oa3lvFmbbkqz2PRmBzn8Kvxu6U4Qt /FQIywhewBIhiwmhr4xFiRqep87IBrnz3mMnEUrUbVTBmqrVfE8Q5PJ4Z115yrGWCP gCNlJlV+Cu9SKs8x55zjEd2KAfQCjuzWT7rRhxMYULSWdOXlpAL89d8jKX8EOtcufk /w0Pdf6T7O37g== 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, Alice Ryhl , Matthew Maurer Subject: Re: [PATCH v2 0/3] Inline helpers into Rust without full LTO In-Reply-To: <20260203-inline-helpers-v2-0-beb8547a03c9@google.com> References: <20260203-inline-helpers-v2-0-beb8547a03c9@google.com> Date: Tue, 17 Mar 2026 09:25:42 +0100 Message-ID: <877brasvzt.fsf@t14s.mail-host-address-is-not-set> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain 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 Tested-by: Andreas Hindborg Reviewed-by: Andreas Hindborg Tested with the rust null block driver patch series [1]. I did a few functional verification tests and a set of performance tests. For the rnull driver, enabling helper inlining with this patch gives an average speedup of 2% over the set of 120 workloads that we publish on [2]. Best regards, Andreas Hindborg [1] https://lore.kernel.org/rust-for-linux/20260216-rnull-v6-19-rc5-send-v1-0-de9a7af4b469@kernel.org/ [2] https://rust-for-linux.com/null-block-driver