[PATCH v6 0/2] Avoid synchronize_rcu() for every thread drop in Rust Binder

From: Alice Ryhl

Date: Tue Jul 07 2026 - 06:48:49 EST


Right now Rust Binder calls synchronize_rcu() more often than is
necessary. Most processes do not use epoll at all, so they don't require
rcu here. Back in Kangrejos I came up with a way to avoid this. Idea is
to move the value that needs rcu to a separate allocation that's easy to
kfree_rcu(). We pay the allocation only when the proc uses epoll using
an "upgrade" strategy - most processes don't.

Based on top of:
https://lore.kernel.org/rust-for-linux/20260707-binder-noderefs-spin-v4-0-7c3c8bc16339@xxxxxxxxxx/

Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
Changes in v6:
- Rebase on v7.2-rc2 and node_ref spinlock change.
- Fix conflict with commit 77bfebf11077 ("rust_binder: fix BINDER_GET_EXTENDED_ERROR")
- Link to v5: https://lore.kernel.org/r/20260611-upgrade-poll-v5-0-497a11c06828@xxxxxxxxxx

Changes in v5:
- Rebase on top of series converting node_refs to spinlock.
- Reword comment claiming node_refs is a mutex.
- Link to v4: https://lore.kernel.org/r/20260523-upgrade-poll-v4-0-f5b4c747eac2@xxxxxxxxxx

Changes in v4:
- Use SetOnce for PollCondVar variable instead of storing inside
spinlock. This avoids calling poll_wait() under the spinlock.
- Link to v3: https://lore.kernel.org/r/20260508-upgrade-poll-v3-0-0c619fe846e8@xxxxxxxxxx

Changes in v3:
- This series was almost entirely rewritten to use a different
implementation strategy. By moving the PollCondVar to the process we
can avoid the upgrade logic entirely.
- Link to v2: https://lore.kernel.org/r/20260213-upgrade-poll-v2-0-984a0fb184fb@xxxxxxxxxx

Changes in v2:
- Change how Rust Binder handles the lock class key.
- Rebase.
- Link to v1: https://lore.kernel.org/r/20260117-upgrade-poll-v1-0-179437b7bd49@xxxxxxxxxx

---
Alice Ryhl (2):
rust: poll: use kfree_rcu() for PollCondVar
rust_binder: move (e)poll wait queue to Process

drivers/android/binder/node.rs | 4 +-
drivers/android/binder/process.rs | 67 ++++++++++++++++++++++--------
drivers/android/binder/thread.rs | 78 +++++++++++++++++------------------
drivers/android/binder/transaction.rs | 6 ++-
rust/kernel/sync/poll.rs | 73 +++++++++++++++++++++++++++++++-
5 files changed, 167 insertions(+), 61 deletions(-)
---
base-commit: 0e77a935cf137e791c672d21bb80441043017ff2
change-id: 20260117-upgrade-poll-37ee2a7a79dd

Best regards,
--
Alice Ryhl <aliceryhl@xxxxxxxxxx>