[PATCH] rust: pci: Mark Device refcount methods inline
Ethan Plant <[email protected]> Tue, 04 Aug 2026 16:24:25 -0700
| Newsgroups | org.kernel.feeds.b4-sent,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
When building the kernel, the following Rust symbols are generated: $ nm vmlinux | grep ' _R' | rustfilt | grep -E 'pci::Device.*(inc_ref|dec_ref)' ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::dec_ref ... T <kernel::pci::Device as kernel::sync::aref::AlwaysRefCounted>::inc_ref These Rust symbols are trivial wrappers around pci_dev_put() and pci_dev_get(), respectively. It doesn't make sense to go through a trivial wrapper for these functions, so mark them inline. Suggested-by: Alice Ryhl <[email protected]> Link: https://github.com/Rust-for-Linux/linux/issues/1145 Signed-off-by: Ethan Plant <[email protected]> --- rust/kernel/pci.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 5071cae6543f..3e80ec1160b3 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -482,11 +482,13 @@ impl<'a> crate::dma::Device<'a> for Device<device::Core<'a>> {} // SAFETY: Instances of `Device` are always reference-counted. unsafe impl crate::sync::aref::AlwaysRefCounted for Device { + #[inline] fn inc_ref(&self) { // SAFETY: The existence of a shared reference guarantees that the refcount is non-zero. unsafe { bindings::pci_dev_get(self.as_raw()) }; } + #[inline] unsafe fn dec_ref(obj: NonNull<Self>) { // SAFETY: The safety requirements guarantee that the refcount is non-zero. unsafe { bindings::pci_dev_put(obj.cast().as_ptr()) } --- base-commit: dc01dfb37b34beeefcfe1c3055364d41a4070c7e change-id: 20260804-inline-wrappers-f869b6e4601e Best regards, -- Ethan Plant <[email protected]>