* Re: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]`
2026-06-11 19:05 [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]` Gary Guo
@ 2026-06-11 23:01 ` Alice Ryhl
2026-06-12 4:40 ` Alexandre Courbot
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Alice Ryhl @ 2026-06-11 23:01 UTC (permalink / raw)
To: Gary Guo
Cc: Alexandre Courbot, Yury Norov, Miguel Ojeda, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Thu, Jun 11, 2026 at 08:05:54PM +0100, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> A `Debug` impl is for debugging and is normally not used, and therefore
> should ideally not be code-generated unless used. However, Rust has no way
> of knowing if a dependent crate is going to use the trait impl or not, so
> unless it is marked as `#[inline]`, it will be code-generated in the
> defining crate (as it is not generic).
>
> Mark the impl generated by bitfield macro `#[inline]`, so they do not stay
> in the binary unless used.
>
> This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes).
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]`
2026-06-11 19:05 [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]` Gary Guo
2026-06-11 23:01 ` Alice Ryhl
@ 2026-06-12 4:40 ` Alexandre Courbot
2026-06-13 5:43 ` Alexandre Courbot
2026-06-13 8:24 ` Miguel Ojeda
2026-06-16 23:37 ` Miguel Ojeda
3 siblings, 1 reply; 7+ messages in thread
From: Alexandre Courbot @ 2026-06-12 4:40 UTC (permalink / raw)
To: Gary Guo
Cc: Gary Guo, Yury Norov, Miguel Ojeda, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Fri Jun 12, 2026 at 4:05 AM JST, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> A `Debug` impl is for debugging and is normally not used, and therefore
> should ideally not be code-generated unless used. However, Rust has no way
> of knowing if a dependent crate is going to use the trait impl or not, so
> unless it is marked as `#[inline]`, it will be code-generated in the
> defining crate (as it is not generic).
>
> Mark the impl generated by bitfield macro `#[inline]`, so they do not stay
> in the binary unless used.
>
> This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes).
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
Ouch, well-spotted. Thanks for this.
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]`
2026-06-12 4:40 ` Alexandre Courbot
@ 2026-06-13 5:43 ` Alexandre Courbot
2026-06-13 8:25 ` Miguel Ojeda
0 siblings, 1 reply; 7+ messages in thread
From: Alexandre Courbot @ 2026-06-13 5:43 UTC (permalink / raw)
To: Gary Guo
Cc: Gary Guo, Yury Norov, Miguel Ojeda, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Fri Jun 12, 2026 at 1:40 PM JST, Alexandre Courbot wrote:
> On Fri Jun 12, 2026 at 4:05 AM JST, Gary Guo wrote:
>> From: Gary Guo <gary@garyguo.net>
>>
>> A `Debug` impl is for debugging and is normally not used, and therefore
>> should ideally not be code-generated unless used. However, Rust has no way
>> of knowing if a dependent crate is going to use the trait impl or not, so
>> unless it is marked as `#[inline]`, it will be code-generated in the
>> defining crate (as it is not generic).
>>
>> Mark the impl generated by bitfield macro `#[inline]`, so they do not stay
>> in the binary unless used.
>>
>> This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes).
>>
>> Signed-off-by: Gary Guo <gary@garyguo.net>
>
> Ouch, well-spotted. Thanks for this.
>
> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Btw, should this be
Fixes: b7b8b4ccdad4 ("rust: extract `bitfield!` macro from `register!`")
?
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]`
2026-06-13 5:43 ` Alexandre Courbot
@ 2026-06-13 8:25 ` Miguel Ojeda
0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2026-06-13 8:25 UTC (permalink / raw)
To: Alexandre Courbot
Cc: Gary Guo, Gary Guo, Yury Norov, Miguel Ojeda, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Sat, Jun 13, 2026 at 7:43 AM Alexandre Courbot <acourbot@nvidia.com> wrote:
>
> Btw, should this be
>
> Fixes: b7b8b4ccdad4 ("rust: extract `bitfield!` macro from `register!`")
>
> ?
I think it is reasonable either way. One can see it as a "size
improvement" or as a "fix" if it was unintentional to not have the
annotation.
It also depends on the magnitude of the size reduction -- if it were
very low, would we see it as a fix?
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]`
2026-06-11 19:05 [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]` Gary Guo
2026-06-11 23:01 ` Alice Ryhl
2026-06-12 4:40 ` Alexandre Courbot
@ 2026-06-13 8:24 ` Miguel Ojeda
2026-06-16 23:37 ` Miguel Ojeda
3 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2026-06-13 8:24 UTC (permalink / raw)
To: Gary Guo
Cc: Alexandre Courbot, Yury Norov, Miguel Ojeda, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Thu, Jun 11, 2026 at 9:06 PM Gary Guo <gary@kernel.org> wrote:
>
> This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes).
That's definitely something :)
I wonder if we could lint this for `fmt` bits.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]`
2026-06-11 19:05 [PATCH] rust: bitfield: mark `Debug` impl as `#[inline]` Gary Guo
` (2 preceding siblings ...)
2026-06-13 8:24 ` Miguel Ojeda
@ 2026-06-16 23:37 ` Miguel Ojeda
3 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2026-06-16 23:37 UTC (permalink / raw)
To: Gary Guo
Cc: Alexandre Courbot, Yury Norov, Miguel Ojeda, Boqun Feng,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Thu, Jun 11, 2026 at 9:06 PM Gary Guo <gary@kernel.org> wrote:
>
> From: Gary Guo <gary@garyguo.net>
>
> A `Debug` impl is for debugging and is normally not used, and therefore
> should ideally not be code-generated unless used. However, Rust has no way
> of knowing if a dependent crate is going to use the trait impl or not, so
> unless it is marked as `#[inline]`, it will be code-generated in the
> defining crate (as it is not generic).
>
> Mark the impl generated by bitfield macro `#[inline]`, so they do not stay
> in the binary unless used.
>
> This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes).
>
> Signed-off-by: Gary Guo <gary@garyguo.net>
Applied to `rust-fixes` -- thanks!
I am going to pick a couple actual fixes in the coming days, so I
decided to pick this one too for the ride since it is trivial. I may
still rebase though.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 7+ messages in thread