diff options
| author | Gary Guo <gary@garyguo.net> | 2026-06-11 20:05:54 +0100 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2026-06-17 01:32:56 +0200 |
| commit | f09d2312d1d44a8b8c9d3bfd33acfe930a6d8250 (patch) | |
| tree | 884f22593540cf520803847e3656802597022026 /rust | |
| parent | 6b5a2b7d9bc156e505f09e698d85d6a1547c1206 (diff) | |
| download | linux-next-f09d2312d1d44a8b8c9d3bfd33acfe930a6d8250.tar.gz linux-next-f09d2312d1d44a8b8c9d3bfd33acfe930a6d8250.zip | |
rust: bitfield: mark `Debug` impl as `#[inline]`
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>
Fixes: b7b8b4ccdad4 ("rust: extract `bitfield!` macro from `register!`")
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260611190555.2298991-1-gary@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/kernel/bitfield.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/rust/kernel/bitfield.rs b/rust/kernel/bitfield.rs index 554a5a2ff0ab..35ede53f2b8e 100644 --- a/rust/kernel/bitfield.rs +++ b/rust/kernel/bitfield.rs @@ -535,6 +535,7 @@ macro_rules! bitfield { // `Debug` implementation. (@debug $name:ident { $($field:ident;)* }) => { impl ::kernel::fmt::Debug for $name { + #[inline] fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result { f.debug_struct(stringify!($name)) .field("<raw>", &::kernel::prelude::fmt!("{:#x}", self.inner)) |
