Re: [PATCH] rust: page:: optimize rust symbol generation for Page
From: Alice Ryhl
Date: Mon Mar 17 2025 - 06:33:26 EST
On Mon, Mar 17, 2025 at 05:40:04PM +0800, Kunwu Chan wrote:
> From: Kunwu Chan <kunwu.chan@xxxxxxxxxxx>
>
> When build the kernel using the llvm-18.1.3-rust-1.85.0-x86_64
> with ARCH=arm64, the following symbols are generated:
>
> $nm vmlinux | grep ' _R'.*Page | rustfilt
> ffff8000805b6f98 T <kernel::page::Page>::alloc_page
> ffff8000805b715c T <kernel::page::Page>::fill_zero_raw
> ffff8000805b720c T <kernel::page::Page>::copy_from_user_slice_raw
> ffff8000805b6fb4 T <kernel::page::Page>::read_raw
> ffff8000805b7088 T <kernel::page::Page>::write_raw
> ffff8000805b72fc T <kernel::page::Page as core::ops::drop::Drop>::drop
>
> These Rust symbols are trivial wrappers around the C functions
> alloc_pages, kunmap_local and __free_pages.
> It doesn't make sense to go through a trivial wrapper for these
> functions, so mark them inline.
>
> Link: https://github.com/Rust-for-Linux/linux/issues/1145
> Suggested-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Co-developed-by: Grace Deng <Grace.Deng006@xxxxxxxxx>
> Signed-off-by: Grace Deng <Grace.Deng006@xxxxxxxxx>
> Signed-off-by: Kunwu Chan <kunwu.chan@xxxxxxxxxxx>
For sure `alloc_page` and `drop` should be inline, but the other methods
are not as simple. It is less clear that they should be inline.
At the very least, the claim that they are a trivial wrapper around
"kunmap_local" is false. They don't just call that method.
Alice