From: "Gary Guo" <gary@garyguo.net>
To: "Alexandre Courbot" <acourbot@nvidia.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
Björn Roy Baron <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>
Cc: "John Hubbard" <jhubbard@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>, "Zhi Wang" <zhiw@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
<linux-kbuild@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<rust-for-linux@vger.kernel.org>, <nova-gpu@lists.linux.dev>,
<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v2 3/7] rust: always inline some init methods
Date: Wed, 27 May 2026 18:54:43 +0100 [thread overview]
Message-ID: <DITNHBFUULNG.2X57K1ATS5AUO@garyguo.net> (raw)
In-Reply-To: <20260527-nova-exports-v2-3-06de4c556d55@nvidia.com>
On Wed May 27, 2026 at 12:52 PM BST, Alexandre Courbot wrote:
> These methods should always be inlined for optimization reasons. Failure
> to do so can also produce symbol names larger than what `modpost`
> supports.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> rust/kernel/alloc/kbox.rs | 2 ++
> rust/kernel/init.rs | 1 +
> rust/kernel/sync/arc.rs | 2 ++
> rust/kernel/types.rs | 3 +++
> 4 files changed, 8 insertions(+)
>
> diff --git a/rust/kernel/alloc/kbox.rs b/rust/kernel/alloc/kbox.rs
> index 2f8c16473c2c..592fffc72e52 100644
> --- a/rust/kernel/alloc/kbox.rs
> +++ b/rust/kernel/alloc/kbox.rs
> @@ -433,6 +433,7 @@ impl<T, A> InPlaceWrite<T> for Box<MaybeUninit<T>, A>
> {
> type Initialized = Box<T, A>;
>
> + #[inline(always)]
> fn write_init<E>(mut self, init: impl Init<T, E>) -> Result<Self::Initialized, E> {
> let slot = self.as_mut_ptr();
> // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
> @@ -442,6 +443,7 @@ fn write_init<E>(mut self, init: impl Init<T, E>) -> Result<Self::Initialized, E
> Ok(unsafe { Box::assume_init(self) })
> }
>
> + #[inline(always)]
> fn write_pin_init<E>(mut self, init: impl PinInit<T, E>) -> Result<Pin<Self::Initialized>, 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 7a0d4559d7b5..36d4bf1959fb 100644
> --- a/rust/kernel/init.rs
> +++ b/rust/kernel/init.rs
> @@ -151,6 +151,7 @@ fn try_pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> Result<Self::Pinne
> /// type.
> ///
> /// If `T: !Unpin` it will not be able to move afterwards.
> + #[inline(always)]
> fn pin_init<E>(init: impl PinInit<T, E>, flags: Flags) -> error::Result<Self::PinnedSelf>
> where
> Error: From<E>,
> diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs
> index 18d6c0d62ce0..973f15165606 100644
> --- a/rust/kernel/sync/arc.rs
> +++ b/rust/kernel/sync/arc.rs
> @@ -712,6 +712,7 @@ fn try_init<E>(init: impl Init<T, E>, flags: Flags) -> Result<Self, E>
> impl<T> InPlaceWrite<T> for UniqueArc<MaybeUninit<T>> {
> type Initialized = UniqueArc<T>;
>
> + #[inline(always)]
> fn write_init<E>(mut self, init: impl Init<T, E>) -> Result<Self::Initialized, E> {
> let slot = self.as_mut_ptr();
> // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
> @@ -721,6 +722,7 @@ fn write_init<E>(mut self, init: impl Init<T, E>) -> Result<Self::Initialized, E
> Ok(unsafe { self.assume_init() })
> }
>
> + #[inline(always)]
> fn write_pin_init<E>(mut self, init: impl PinInit<T, E>) -> Result<Pin<Self::Initialized>, E> {
> let slot = self.as_mut_ptr();
> // SAFETY: When init errors/panics, slot will get deallocated but not dropped,
> diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
> index ac316fd7b538..381a06ee0d59 100644
> --- a/rust/kernel/types.rs
> +++ b/rust/kernel/types.rs
> @@ -367,6 +367,7 @@ pub const fn zeroed() -> Self {
> /// This function is safe, because the `T` inside of an `Opaque` is allowed to be
> /// uninitialized. Additionally, access to the inner `T` requires `unsafe`, so the caller needs
> /// to verify at that point that the inner value is valid.
> + #[inline(always)]
> pub fn ffi_init(init_func: impl FnOnce(*mut T)) -> impl PinInit<Self> {
> // SAFETY: We contain a `MaybeUninit`, so it is OK for the `init_func` to not fully
> // initialize the `T`.
Are you sure this (and other `impl PinInit`-returning functions) are actually
causing issue? They just return an initializer and the actual init code is not
marked as `#[inline]`.
Best,
Gary
> @@ -386,6 +387,7 @@ pub fn ffi_init(init_func: impl FnOnce(*mut T)) -> impl PinInit<Self> {
> /// This function is safe, because the `T` inside of an `Opaque` is allowed to be
> /// uninitialized. Additionally, access to the inner `T` requires `unsafe`, so the caller needs
> /// to verify at that point that the inner value is valid.
> + #[inline(always)]
> pub fn try_ffi_init<E>(
> init_func: impl FnOnce(*mut T) -> Result<(), E>,
> ) -> impl PinInit<Self, E> {
> @@ -417,6 +419,7 @@ pub const fn cast_from(this: *const T) -> *const Self {
>
> impl<T> Wrapper<T> for Opaque<T> {
> /// Create an opaque pin-initializer from the given pin-initializer.
> + #[inline(always)]
> fn pin_init<E>(slot: impl PinInit<T, E>) -> impl PinInit<Self, E> {
> Self::try_ffi_init(|ptr: *mut T| {
> // SAFETY:
next prev parent reply other threads:[~2026-05-27 17:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 11:52 [PATCH v2 0/7] gpu: drm: nova: enable calling into nova-core Alexandre Courbot
2026-05-27 11:52 ` [PATCH v2 1/7] scripts: modpost: detect and report truncated buf_printf() output Alexandre Courbot
2026-05-27 17:18 ` Nathan Chancellor
2026-05-28 2:21 ` Claude review: " Claude Code Review Bot
2026-05-27 11:52 ` [PATCH v2 2/7] pin_init: always inline the #ident and #project_ident methods Alexandre Courbot
2026-05-27 17:49 ` Gary Guo
2026-05-28 2:22 ` Claude review: " Claude Code Review Bot
2026-05-27 11:52 ` [PATCH v2 3/7] rust: always inline some init methods Alexandre Courbot
2026-05-27 17:54 ` Gary Guo [this message]
2026-05-28 2:22 ` Claude review: " Claude Code Review Bot
2026-05-27 11:52 ` [PATCH v2 4/7] gpu: nova-core: export Rust symbols for dependent modules Alexandre Courbot
2026-05-28 2:22 ` Claude review: " Claude Code Review Bot
2026-05-27 11:52 ` [PATCH v2 5/7] gpu: nova-core: emit Rust metadata " Alexandre Courbot
2026-05-28 2:22 ` Claude review: " Claude Code Review Bot
2026-05-27 11:52 ` [PATCH v2 6/7] gpu: drm: nova: build after nova-core metadata Alexandre Courbot
2026-05-28 2:22 ` Claude review: " Claude Code Review Bot
2026-05-27 11:52 ` [PATCH POC v2 7/7] drm: nova: demonstrate interaction with nova-core Alexandre Courbot
2026-05-28 2:22 ` Claude review: " Claude Code Review Bot
2026-05-28 2:21 ` Claude review: gpu: drm: nova: enable calling into nova-core Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DITNHBFUULNG.2X57K1ATS5AUO@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nathan@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox