Skip to contentSkip to conversation

rust_binder: avoid name mangling for get_work[_local]

PATCH Superseded Alice Ryhl 3 participants 4 messages Feb 13 – Feb 14

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alice Ryhl

author maintainer
#0 lore raw

PATCH 1/1 rust_binder: avoid name mangling for get_work[_local]

Currently ps -A shows processes waiting on schedule() in functions with names such as do_epoll_wait, wait_woken, and the impeccably named _RNvMs2_NtCs8QPsHWIn21X_16rust_binder_main6threadNtB5_6Thread8get_work.

To improve how ps output looks, give explicit non-mangled names to the functions where Rust Binder calls schedule(), since these are the most likely places to show up on ps output.

The name of rust_binder_waitlcl is truncated instead of using _local suffix because rust_binder_wait_local is sufficiently long that ps shows unaligned output.

---
 drivers/android/binder/process.rs | 1 +
 drivers/android/binder/thread.rs  | 2 ++
 2 files changed, 3 insertions(+)
drivers/android/binder/process.rs +1 -0
index 132055b4790f0ec69a87635b498909df2bf475e2..cf7425e74183966063ab53114637aec7b3672ac8 100644
@@ -1436,6 +1436,7 @@ pub(crate) fn drop_outstanding_txn(&self) {
         }
     }
 
+    #[export_name = "rust_binder_freeze"]
     pub(crate) fn ioctl_freeze(&self, info: &BinderFreezeInfo) -> Result {
         if info.enable == 0 {
             let msgs = self.prepare_freeze_messages()?;
drivers/android/binder/thread.rs +2 -0
index 1f1709a6a77abc1c865cc9387e7ba7493448c71d..2ca8ed8962314b58a3cfeb3ae0aa0ed60f179433 100644
@@ -514,6 +514,7 @@ pub(crate) fn has_current_transaction(&self) -> bool {
     /// Attempts to fetch a work item from the thread-local queue. The behaviour if the queue is
     /// empty depends on `wait`: if it is true, the function waits for some work to be queued (or a
     /// signal); otherwise it returns indicating that none is available.
+    #[export_name = "rust_binder_waitlcl"]
     fn get_work_local(self: &Arc<Self>, wait: bool) -> Result<Option<DLArc<dyn DeliverToRead>>> {
         {
             let mut inner = self.inner.lock();
@@ -552,6 +553,7 @@ fn get_work_local(self: &Arc<Self>, wait: bool) -> Result<Option<DLArc<dyn Deliv
     ///
     /// This must only be called when the thread is not participating in a transaction chain. If it
     /// is, the local version (`get_work_local`) should be used instead.
+    #[export_name = "rust_binder_wait"]
     fn get_work(self: &Arc<Self>, wait: bool) -> Result<Option<DLArc<dyn DeliverToRead>>> {
         // Try to get work from the thread's work queue, using only a local lock.
         {

---
base-commit: cee73b1e840c154f64ace682cb477c1ae2e29cc4
change-id: 20260213-rust-binder-ps-46d9d060243a

Best regards,

Signature · 1 line
Alice Ryhl <[email protected]>
#1 lore raw

(Sorry Alice, resending as I didn't hit "Reply All". I was travelling and not on my usual email setup).

Quoted 8 lines · Alice Ryhl

Currently ps -A shows processes waiting on schedule() in functions with names such as do_epoll_wait, wait_woken, and the impeccably named _RNvMs2_NtCs8QPsHWIn21X_16rust_binder_main6threadNtB5_6Thread8get_work.

To improve how ps output looks, give explicit non-mangled names to the functions where Rust Binder calls schedule(), since these are the most likely places to show up on ps output.

Quoted 6 lines

The name of rust_binder_waitlcl is truncated instead of using _local suffix because rust_binder_wait_local is sufficiently long that ps shows unaligned output.

I don't think this the direction that we should head for. It's not feasible to do this for all users that can possibly call schedule(). In edition 2024 forwards, export_name is also an unsafe attribute and it will become tedious to justify all usages.

I think if the function names are demangled, it won't be too bad?

Best,
Gary

Quoted 54 lines
---
 drivers/android/binder/process.rs | 1 +
 drivers/android/binder/thread.rs  | 2 ++
 2 files changed, 3 insertions(+)
drivers/android/binder/process.rs +1 -0
index 132055b4790f0ec69a87635b498909df2bf475e2..cf7425e74183966063ab53114637aec7b3672ac8 100644
@@ -1436,6 +1436,7 @@ pub(crate) fn drop_outstanding_txn(&self) {
         }
     }
 
+    #[export_name = "rust_binder_freeze"]
     pub(crate) fn ioctl_freeze(&self, info: &BinderFreezeInfo) -> 
 Result {
         if info.enable == 0 {
             let msgs = self.prepare_freeze_messages()?;
drivers/android/binder/thread.rs +0 -0
index 1f1709a6a77abc1c865cc9387e7ba7493448c71d..2ca8ed8962314b58a3cfeb3ae0aa0ed60f179433 100644
@@ -514,6 +514,7 @@ pub(crate) fn has_current_transaction(&self) -> 
 bool {
     /// Attempts to fetch a work item from the thread-local queue. The 

behaviour if the queue is

     /// empty depends on `wait`: if it is true, the function waits for 
some work to be queued (or a
     /// signal); otherwise it returns indicating that none is 
available.
+    #[export_name = "rust_binder_waitlcl"]
     fn get_work_local(self: &Arc<Self>, wait: bool) -> 
Result<Option<DLArc<dyn DeliverToRead>>> {
         {
             let mut inner = self.inner.lock();
drivers/android/binder/thread.rs +0 -0
@@ -552,6 +553,7 @@ fn get_work_local(self: &Arc<Self>, wait: bool) -> 

Result<Option<DLArc<dyn Deliv

     ///
     /// This must only be called when the thread is not participating 
in a transaction chain. If it
     /// is, the local version (`get_work_local`) should be used 
instead.
+    #[export_name = "rust_binder_wait"]
     fn get_work(self: &Arc<Self>, wait: bool) -> 
Result<Option<DLArc<dyn DeliverToRead>>> {
         // Try to get work from the thread's work queue, using only a 
local lock.
         {

---
base-commit: cee73b1e840c154f64ace682cb477c1ae2e29cc4
change-id: 20260213-rust-binder-ps-46d9d060243a

Best regards,

author maintainer
#2 lore raw
Quoted 29 lines · On Sat, Feb 14, 2026 at 12:52 AM <[email protected]> wrote:

(Sorry Alice, resending as I didn't hit "Reply All". I was travelling and not on my usual email setup).

Quoted 8 lines · Alice Ryhl

Currently ps -A shows processes waiting on schedule() in functions with names such as do_epoll_wait, wait_woken, and the impeccably named _RNvMs2_NtCs8QPsHWIn21X_16rust_binder_main6threadNtB5_6Thread8get_work.

To improve how ps output looks, give explicit non-mangled names to the functions where Rust Binder calls schedule(), since these are the most likely places to show up on ps output.

Quoted 7 lines

The name of rust_binder_waitlcl is truncated instead of using _local suffix because rust_binder_wait_local is sufficiently long that ps shows
unaligned output.

I don't think this the direction that we should head for. It's not feasible to
do this for all users that can possibly call schedule(). In edition 2024
forwards, export_name is also an unsafe attribute and it will become tedious to
justify all usages.

Quoted 1 line

I think if the function names are demangled, it won't be too bad?

This is mostly meant as a temporary fix. Ideally ps can demangle them.

(Though even demangled, they are still too long for ps -A output as it is right now.)

Alice

#3 lore raw
Quoted 2 lines · Alice Ryhl

This is mostly meant as a temporary fix. Ideally ps can demangle them.

In that case, could we please write that in the commit message, or even better, add a one-line comment on top of the attributes?

Thanks!

Cheers,
Miguel