Skip to contentSkip to conversation

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

PATCH Applied Ritvik Gupta 4 participants 5 messages Aug 11, 2025 – Sep 14, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 rust/kernel/cpu.rs | 1 +
 1 file changed, 1 insertion(+)
rust/kernel/cpu.rs +1 -0
index 5de730c8d817..cb6c0338ef5a 100644
@@ -109,6 +109,7 @@ pub fn as_u32(&self) -> u32 {
     /// 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()) }

base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585

Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Ritvik Gupta

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.

Quoted 5 lines

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

Regards,
Boqun

Quoted 21 lines
---
 rust/kernel/cpu.rs | 1 +
 1 file changed, 1 insertion(+)
rust/kernel/cpu.rs +1 -0
index 5de730c8d817..cb6c0338ef5a 100644
@@ -109,6 +109,7 @@ pub fn as_u32(&self) -> u32 {
     /// 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()) }

base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585

Signature · 1 line
2.50.1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Ritvik Gupta
Quoted 11 lines · Ritvik Gupta

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.

Quoted 5 lines

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

#3 lore raw
In reply to Ritvik Gupta
Quoted 12 lines · Ritvik Gupta

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.

Quoted 5 lines

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

If no one is planning to pick this one, I will -- thanks!

Cheers,
Miguel

Applied
#4 lore raw
In reply to Ritvik Gupta
Quoted 12 lines · Ritvik Gupta

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.

Quoted 5 lines

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

Applied to rust-next -- thanks everyone!

Cheers,
Miguel