rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] kbuild: rust: provide an option to inline C helpers into Rust
@ 2024-05-29 20:28 Gary Guo
  2024-05-29 20:28 ` [RFC PATCH 1/2] kbuild: rust: auto generate rust helper exports Gary Guo
  2024-05-29 20:28 ` [RFC PATCH 2/2] kbuild: rust: provide an option to inline C helpers into Rust Gary Guo
  0 siblings, 2 replies; 7+ messages in thread
From: Gary Guo @ 2024-05-29 20:28 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl
  Cc: rust-for-linux

Currently we have quite a few helper function to aid calling from Rust
into inline/macro functions in C. These functions are typically
implemented with macros or inline functions because we want them to be
fast, so we want to actually have them inlined without the additional
function call overhead. However, we also don't want to re-implement
these functions in Rust to avoid accidental behaviour divergence.

This RFC presents an option `RUST_LTO_HELPERS` to inline C helpers into
Rust. This is similar to LTO, but we perform the extra inlining and
optimisation per Rust crate (compilation unit) instead of at final
linking time, thus has better compilation speed. It also means that this
presented approach work for loadable modules as well.

Andreas tested a variant of this patchset with his Rust NVMe driver and
saw an average performance gain of 3.4% with the option enabled.

Gary Guo (2):
  kbuild: rust: auto generate rust helper exports
  kbuild: rust: provide an option to inline C helpers into Rust

 Makefile               |  4 ++-
 lib/Kconfig.debug      | 10 +++++++
 rust/Makefile          | 35 +++++++++++++++++++++---
 rust/exports.c         |  4 +++
 rust/helpers.c         | 61 +++++++++++++++---------------------------
 scripts/Makefile.build |  5 +++-
 6 files changed, 74 insertions(+), 45 deletions(-)


base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
-- 
2.42.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-06-12 21:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 20:28 [RFC PATCH 0/2] kbuild: rust: provide an option to inline C helpers into Rust Gary Guo
2024-05-29 20:28 ` [RFC PATCH 1/2] kbuild: rust: auto generate rust helper exports Gary Guo
2024-05-29 20:28 ` [RFC PATCH 2/2] kbuild: rust: provide an option to inline C helpers into Rust Gary Guo
2024-05-29 20:45   ` Gary Guo
2024-06-07 14:40   ` Matthew Maurer
2024-06-12 16:26     ` Gary Guo
2024-06-12 21:28   ` Boqun Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).