Description
When writing abstractions around core C apis, we often have Rust functions that do nothing other than call a C function. In those cases, we don't want the generated code to have a trivial Rust wrapper around the C function — Rust should inline it and generate a direct call into C.
However, in some cases that requires an #[inline] marker. Many methods in the kernel is missing it, and so this issue tracks such additions.
A few cases where I know that this is happening:
rust/kernel/task.rsrust/kernel/page.rsrust/kernel/sync/condvar.rsrust/kernel/fs.rsspecificallyFileDescriptorReservationrust/kernel/seq_file.rsrust/kernel/uaccess.rs
To find these, you can inspect the Rust symbols yourself by building the kernel and running this command:
nm vmlinux | grep ' _R' | rustfilt
Examples of good patches that make this kind of change:
If you submit a patch that makes this kind of change, please make sure to have a good commit message (see the examples above).
This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes (including generating the documentation if changed, running the Rust doctests if changed, etc.), to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and to add a Suggested-by: tag and a Link: tag to this issue. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details.
Please take this issue only if you are new to the kernel development process and you would like to use it as a test to submit your first patch to the kernel. Please do not take it if you do not plan to make other contributions to the kernel.
Activity
panosfol commentedon Mar 5, 2025
Hello! I would like to tackle this issue
ojeda commentedon Mar 5, 2025
Thanks, please go ahead!
Darksonn commentedon Mar 6, 2025
I recommend that you don't try to tackle every single method in one go. Start with one or two files and send a patch just for those, like the example patches did.
panosfol commentedon Mar 6, 2025
Sounds good!
ethancedwards8 commentedon Mar 10, 2025
Giving it a try: https://lkml.org/lkml/2025/3/9/512
rust/kernel/faux: mark Registration methods inline
rust: task: mark Task methods inline
ojeda commentedon Mar 10, 2025
Thanks both for the patches!
By the way, please prefer lore.kernel.org for links, e.g. @ethancedwards8's patch is: https://lore.kernel.org/rust-for-linux/20250309-faux-inline-v1-1-c1b692862433@ethancedwards.com/
rust/kernel/faux: mark Registration methods inline
ethancedwards8 commentedon Mar 11, 2025
Yeah, I typically use lore.kernel.org, but last night when I was sending the patch lore.kernel.org was having some issues (I was getting 504 errors), so I used lkml.org instead. I will use lore.kernel.org exclusively in the future, however
antonio-hickey commentedon Mar 11, 2025
Giving a try for methods in uaccess.
https://lore.kernel.org/all/0100019582fc6956-3b420cce-f122-4a26-8fea-94000b22bc90-000000@email.amazonses.com
#1147
KunWuChan commentedon Mar 11, 2025
Thanks for the hint, I'll submit for the unfinished part, allow me to add a Suggested-by tag.
charmitro commentedon Mar 11, 2025
Hi @KunWuChan, please note the following regarding issues labeled as "good-first-issue":
39 remaining items
rust: page: mark Page::nid as inline
rust: page: mark Page::nid as inline
rust: page: mark Page::nid as inline
rust: page: mark Page::nid as inline
rust: page: mark Page::nid as inline
rust: sync: completion: Mark inline complete_all and wait_for_completion
rust: sync: completion: Mark inline complete_all and wait_for_completion
usb: rust: mark Device and Interface methods as inline
rust: pci: Mark Device refcount methods inline
i2c: rust: mark I2cAdapter methods as inline
i2c: rust: mark I2cAdapter methods as inline
rust: sync: rcu: Mark Guard methods as inline
rust: sync: Mark CondVar::notify_*() inline
rust: sync: Mark PollCondVar::drop() inline
rust: task: Mark Task methods inline