]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rust: kernel: cpu: mark `CpuId::current()` inline
authorRitvik Gupta <ritvikfoss@gmail.com>
Mon, 11 Aug 2025 01:19:58 +0000 (06:49 +0530)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 14 Sep 2025 21:58:45 +0000 (23:58 +0200)
When building the kernel using llvm-20.1.7-rust-1.89.0-x86_64,
this symbol is generated:

$ llvm-nm --demangle vmlinux | grep CpuId
ffffffff84c77450 T <kernel::cpu::CpuId>::current

However, this Rust symbol is a trivial wrapper around
`raw_smp_processor_id` function. It doesn't make sense
to go through a trivial wrapper for such functions,
so mark it inline.

After applying this patch, the above command will produce no output.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1145
Signed-off-by: Ritvik Gupta <ritvikfoss@gmail.com>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/cpu.rs

index 5de730c8d81722873ba2349a1c9c4d6c17701134..cb6c0338ef5a613746ba8282468018d33744539c 100644 (file)
@@ -109,6 +109,7 @@ impl CpuId {
     /// unexpectedly due to preemption or CPU migration. It should only be
     /// used when the context ensures that the task remains on the same CPU
     /// or the users could use a stale (yet valid) CPU ID.
+    #[inline]
     pub fn current() -> Self {
         // SAFETY: raw_smp_processor_id() always returns a valid CPU ID.
         unsafe { Self::from_u32_unchecked(bindings::raw_smp_processor_id()) }