summaryrefslogtreecommitdiffstats
path: root/rust/kernel/alloc/allocator.rs
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2025-01-05 19:40:06 +0000
committerMiguel Ojeda <ojeda@kernel.org>2025-03-06 20:49:06 +0100
commit41b6a8122d888299e3e437dae3a36431e6dfd5c9 (patch)
tree516c026b431de8d25cf8b27d049a335bf37b62ee /rust/kernel/alloc/allocator.rs
parentc3e4049a681ec86bfe56a05bf6c7ed68ae9cf364 (diff)
downloadlinux-41b6a8122d888299e3e437dae3a36431e6dfd5c9.tar.gz
linux-41b6a8122d888299e3e437dae3a36431e6dfd5c9.tar.bz2
linux-41b6a8122d888299e3e437dae3a36431e6dfd5c9.zip
rust: alloc: make `ReallocFunc::call` inline
This function can be called with different function pointers when different allocator (e.g. Kmalloc, Vmalloc, KVmalloc), however since this function is not polymorphic, only one instance is generated, and function pointers are used. Given that this function is called for any Rust-side allocation/deallocation, performance matters a lot, so making this function inlineable. This is discovered when doing helper inlining work, since it's discovered that even with helpers inlined, rust_helper_ symbols are still present in final vmlinux binary, and it turns out this function is inhibiting the inlining, and introducing indirect function calls. Signed-off-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250105194054.545201-4-gary@garyguo.net Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/alloc/allocator.rs')
-rw-r--r--rust/kernel/alloc/allocator.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/kernel/alloc/allocator.rs b/rust/kernel/alloc/allocator.rs
index 439985e29fbc..aa2dfa9dca4c 100644
--- a/rust/kernel/alloc/allocator.rs
+++ b/rust/kernel/alloc/allocator.rs
@@ -80,6 +80,7 @@ impl ReallocFunc {
/// This method has the same guarantees as `Allocator::realloc`. Additionally
/// - it accepts any pointer to a valid memory allocation allocated by this function.
/// - memory allocated by this function remains valid until it is passed to this function.
+ #[inline]
unsafe fn call(
&self,
ptr: Option<NonNull<u8>>,