Skip to content

tests: add test for symbol length#149

Open
nbdd0121 wants to merge 1 commit intomainfrom
dev/symbol-length
Open

tests: add test for symbol length#149
nbdd0121 wants to merge 1 commit intomainfrom
dev/symbol-length

Conversation

@nbdd0121
Copy link
Copy Markdown
Member

@nbdd0121 nbdd0121 commented May 8, 2026

__pinned_init or __init functions are natural inline boundaries. Things within them calling into helper functions should be inlined, and wrapping functions that forwarding call to them should be, too. But these functions themselves can contain complex initialization, so it's best to leave it to the compilers to decide if they're inlineable.

As a result, these symbols do show up in the symbol table when they're not inlined. Linux kernel has 512 byte symbol length limit, so we need to keep them small. Add a test to ensure that any growth of them are being considered and not accidental.

`__pinned_init` or `__init` functions are natural inline boundaries. Things
within them calling into helper functions should be inlined, and wrapping
functions that forwarding call to them should be, too. But these functions
themselves can contain complex initialization, so it's best to leave it to
the compilers to decide if they're inlineable.

As a result, these symbols do show up in the symbol table when they're not
inlined. Linux kernel has 512 byte symbol length limit, so we need to keep
them small. Add a test to ensure that any growth of them are being
considered and not accidental.

Signed-off-by: Gary Guo <gary@garyguo.net>
@nbdd0121
Copy link
Copy Markdown
Member Author

nbdd0121 commented May 8, 2026

An alternative is to mark them as #[inline(always)] and have the closure (generated by pin_init!() macro) themselves being where the bulk of the code lives.

Actually, that's probably better, because if they're created inside a new function, then the generated symbol name is just going to be new::{closure#0} after mangling. E.g.

<kernel::scatterlist::SGTable<kernel::scatterlist::Owned<kernel::alloc::kvec::Vec<u8, kernel::alloc::allocator::Vmalloc>>>>::new::{closure#0}

That's more clear than <pin_init::__internal::InitClosure<..., ..., ...> as pin_init::PinInit<...>>::__pinned_init

@nbdd0121
Copy link
Copy Markdown
Member Author

nbdd0121 commented May 8, 2026

The type name of the initializer also shows up in generic code that uses it, too, e.g. InPlaceInit. So we still want shorter symbol names for these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant