Hi Alice, Alice Ryhl <[email protected]> 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/[email protected]/ > > Signed-off-by: Alice Ryhl <[email protected]> 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/[email protected]/
