Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: kernel: cpu: mark `CpuId::current()` inline

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>

authored by

Ritvik Gupta and committed by
Miguel Ojeda
67ff56ce 099381a0

+1
+1
rust/kernel/cpu.rs
··· 109 109 /// unexpectedly due to preemption or CPU migration. It should only be 110 110 /// used when the context ensures that the task remains on the same CPU 111 111 /// or the users could use a stale (yet valid) CPU ID. 112 + #[inline] 112 113 pub fn current() -> Self { 113 114 // SAFETY: raw_smp_processor_id() always returns a valid CPU ID. 114 115 unsafe { Self::from_u32_unchecked(bindings::raw_smp_processor_id()) }