From: Alexandre Courbot Date: Fri, 5 Jun 2026 08:31:51 +0000 (+0900) Subject: rust: inline some init methods X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bf626dc90ff49439584b2693c9a0e717cf0c38a;p=thirdparty%2Fkernel%2Flinux.git rust: inline some init methods These methods should be inlined for optimization reasons. Failure to do so can also produce symbol names larger than what `modpost` or `objtool` can handle. Signed-off-by: Alexandre Courbot Reviewed-by: Gary Guo Link: https://patch.msgid.link/20260605-nova-exports-v4-1-e948c287407c@nvidia.com Signed-off-by: Miguel Ojeda --- diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs index 31b2588ed5bf9..80eb39364e86e 100644 --- a/rust/kernel/alloc/kbox.rs +++ b/rust/kernel/alloc/kbox.rs @@ -437,6 +437,7 @@ where { type Initialized = Box; + #[inline] fn write_init(mut self, init: impl Init) -> Result { let slot = self.as_mut_ptr(); // SAFETY: When init errors/panics, slot will get deallocated but not dropped, @@ -446,6 +447,7 @@ where Ok(unsafe { Box::assume_init(self) }) } + #[inline] fn write_pin_init(mut self, init: impl PinInit) -> Result, E> { let slot = self.as_mut_ptr(); // SAFETY: When init errors/panics, slot will get deallocated but not dropped, diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index 7a0d4559d7b5e..05a12e869a57c 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -151,6 +151,7 @@ pub trait InPlaceInit: Sized { /// type. /// /// If `T: !Unpin` it will not be able to move afterwards. + #[inline] fn pin_init(init: impl PinInit, flags: Flags) -> error::Result where Error: From, @@ -168,6 +169,7 @@ pub trait InPlaceInit: Sized { E: From; /// Use the given initializer to in-place initialize a `T`. + #[inline] fn init(init: impl Init, flags: Flags) -> error::Result where Error: From, diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index 18d6c0d62ce03..feca07e8d13d1 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -712,6 +712,7 @@ impl InPlaceInit for UniqueArc { impl InPlaceWrite for UniqueArc> { type Initialized = UniqueArc; + #[inline] fn write_init(mut self, init: impl Init) -> Result { let slot = self.as_mut_ptr(); // SAFETY: When init errors/panics, slot will get deallocated but not dropped, @@ -721,6 +722,7 @@ impl InPlaceWrite for UniqueArc> { Ok(unsafe { self.assume_init() }) } + #[inline] fn write_pin_init(mut self, init: impl PinInit) -> Result, E> { let slot = self.as_mut_ptr(); // SAFETY: When init errors/panics, slot will get deallocated but not dropped, @@ -782,6 +784,7 @@ impl UniqueArc> { } /// Initialize `self` using the given initializer. + #[inline] pub fn init_with(mut self, init: impl Init) -> core::result::Result, E> { // SAFETY: The supplied pointer is valid for initialization. match unsafe { init.__init(self.as_mut_ptr()) } { @@ -792,6 +795,7 @@ impl UniqueArc> { } /// Pin-initialize `self` using the given pin-initializer. + #[inline] pub fn pin_init_with( mut self, init: impl PinInit,