Skip to contentSkip to conversation

rust: sync: optimize Rust symbol generation for PollCondVar

PATCH Applied Kunwu Chan 5 participants 6 messages Mar 17, 2025 – Jul 3, 2025

Subsystems (3)
lore
Share & tools
lore

Kunwu Chan

author
#0 lore raw

PATCH v2 1/1 rust: sync: optimize Rust symbol generation for PollCondVar

From: Kunwu Chan <[email protected]>

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'.*PollCondVar | rustfilt
... T <kernel::sync::poll::PollCondVar>::new::{closure#0}::{closure#0}::panic_cold_explicit ... T <kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop ... T <kernel::sync::poll::PollCondVar as core::ops::drop::Drop>::drop

This Rust symbol
(<kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop) is trivial wrappers around the C functions __wake_up_pollfree and synchronize_rcu. It doesn't make sense to go through a trivial wrapper for its functions,so mark it inline.

---
Changes in v2:
- Add link and Suggested-by
- Reword commit msg

---
 rust/kernel/sync/poll.rs | 1 +
 1 file changed, 1 insertion(+)
rust/kernel/sync/poll.rs +1 -0
index d5f17153b424..a4f92c545fec 100644
@@ -107,6 +107,7 @@ fn deref(&self) -> &CondVar {
 
 #[pinned_drop]
 impl PinnedDrop for PollCondVar {
+    #[inline]
     fn drop(self: Pin<&mut Self>) {
         // Clear anything registered using `register_wait`.
         //
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 16 lines · Kunwu Chan

From: Kunwu Chan <[email protected]>

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'.*PollCondVar | rustfilt
... T <kernel::sync::poll::PollCondVar>::new::{closure#0}::{closure#0}::panic_cold_explicit ... T <kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop ... T <kernel::sync::poll::PollCondVar as core::ops::drop::Drop>::drop

This Rust symbol
(<kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop) is trivial wrappers around the C functions __wake_up_pollfree and synchronize_rcu. It doesn't make sense to go through a trivial wrapper for its functions,so mark it inline.

Quoted 5 lines

---
Cheers,
Benno

Quoted 7 lines

---
Changes in v2:
- Add link and Suggested-by
- Reword commit msg

---
 rust/kernel/sync/poll.rs | 1 +
 1 file changed, 1 insertion(+)
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Kunwu Chan
Quoted 16 lines · Kunwu Chan

From: Kunwu Chan <[email protected]>

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'.*PollCondVar | rustfilt
... T <kernel::sync::poll::PollCondVar>::new::{closure#0}::{closure#0}::panic_cold_explicit ... T <kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop ... T <kernel::sync::poll::PollCondVar as core::ops::drop::Drop>::drop

This Rust symbol
(<kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop) is trivial wrappers around the C functions __wake_up_pollfree and synchronize_rcu. It doesn't make sense to go through a trivial wrapper for its functions,so mark it inline.

Quoted 5 lines
#3 lore raw
In reply to Kunwu Chan
Quoted 16 lines · Kunwu Chan

From: Kunwu Chan <[email protected]>

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'.*PollCondVar | rustfilt
... T <kernel::sync::poll::PollCondVar>::new::{closure#0}::{closure#0}::panic_cold_explicit ... T <kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop ... T <kernel::sync::poll::PollCondVar as core::ops::drop::Drop>::drop

This Rust symbol
(<kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop) is trivial wrappers around the C functions __wake_up_pollfree and synchronize_rcu. It doesn't make sense to go through a trivial wrapper for its functions,so mark it inline.

Quoted 6 lines

Queued for future tests and reviews. Thanks!

Regards,
Boqun

Quoted 23 lines

---
Changes in v2:
- Add link and Suggested-by
- Reword commit msg

---
 rust/kernel/sync/poll.rs | 1 +
 1 file changed, 1 insertion(+)
rust/kernel/sync/poll.rs +1 -0
index d5f17153b424..a4f92c545fec 100644
@@ -107,6 +107,7 @@ fn deref(&self) -> &CondVar {
 
 #[pinned_drop]
 impl PinnedDrop for PollCondVar {
+    #[inline]
     fn drop(self: Pin<&mut Self>) {
         // Clear anything registered using `register_wait`.
         //
Signature · 1 line
2.43.0
author
#4 lore raw
Quoted 17 lines · Boqun Feng
Quoted 16 lines · Kunwu Chan

From: Kunwu Chan <[email protected]>

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'.*PollCondVar | rustfilt
... T <kernel::sync::poll::PollCondVar>::new::{closure#0}::{closure#0}::panic_cold_explicit ... T <kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop ... T <kernel::sync::poll::PollCondVar as core::ops::drop::Drop>::drop

This Rust symbol
(<kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop) is trivial wrappers around the C functions __wake_up_pollfree and synchronize_rcu. It doesn't make sense to go through a trivial wrapper for its functions,so mark it inline.

Quoted 7 lines
Quoted 6 lines

Queued for future tests and reviews. Thanks!

Ok, if need do testing-related work, feel free to contact me

Quoted 27 lines

Regards,
Boqun

Quoted 23 lines

---
Changes in v2:
- Add link and Suggested-by
- Reword commit msg

---
  rust/kernel/sync/poll.rs | 1 +
  1 file changed, 1 insertion(+)
rust/kernel/sync/poll.rs +1 -0
index d5f17153b424..a4f92c545fec 100644
@@ -107,6 +107,7 @@ fn deref(&self) -> &CondVar {
 
  #[pinned_drop]
  impl PinnedDrop for PollCondVar {
+    #[inline]
      fn drop(self: Pin<&mut Self>) {
          // Clear anything registered using `register_wait`.
          //
Signature · 1 line
2.43.0
Signature · 2 lines
Thanks,
  Kunwu.Chan(Tao.Chan)
merge bot Applied
#5 lore raw

[tip: sched/core] rust: sync: Mark PollCondVar::drop() inline

In reply to Kunwu Chan
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     11867144ff81ab98f4b11c99716c3e8b714b8755
Gitweb:        https://git.kernel.org/tip/11867144ff81ab98f4b11c99716c3e8b714b8755
Author:        Kunwu Chan <[email protected]>
AuthorDate:    Mon, 17 Mar 2025 10:52:05 +08:00
Committer:     Boqun Feng <[email protected]>
CommitterDate: Tue, 24 Jun 2025 10:23:48 -07:00

rust: sync: Mark PollCondVar::drop() inline

When building 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'.*PollCondVar | rustfilt
... T <kernel::sync::poll::PollCondVar as kernel::init::PinnedDrop>::drop
...

This Rust symbol is trivial wrappers around the C functions __wake_up_pollfree() and synchronize_rcu(). It doesn't make sense to go through a trivial wrapper for its functions, so mark it inline.

[boqun: Reword the commit title and re-format the commit log per tip tree's requirement, remove unnecessary information from "nm vmlinux" result.]

---
 rust/kernel/sync/poll.rs | 1 +
 1 file changed, 1 insertion(+)
rust/kernel/sync/poll.rs +1 -0
index d7e6e59..7b973d7 100644
@@ -107,6 +107,7 @@ impl Deref for PollCondVar {
 
 #[pinned_drop]
 impl PinnedDrop for PollCondVar {
+    #[inline]
     fn drop(self: Pin<&mut Self>) {
         // Clear anything registered using `register_wait`.
         //