From: Alice Ryhl <aliceryhl@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Carlos Llamas <cmllamas@google.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 6/6] rust_binder: update Process::node_refs to use SpinLock
Date: Tue, 09 Jun 2026 09:33:12 +0000 [thread overview]
Message-ID: <20260609-binder-noderefs-spin-v2-6-eafde2ff376c@google.com> (raw)
In-Reply-To: <20260609-binder-noderefs-spin-v2-0-eafde2ff376c@google.com>
Unfortunately the current use of a mutex for this lock leads to priority
inversion. Traces have been observed where a process is trying to obtain
this mutex for 22ms, but it's unable to do so because the thread holding
the lock is scheduled out. Since this occurred on a UI thread, that is
an extremely long delay.
Code paths that might sleep under this lock have already been updated in
patches leading up to this one.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
drivers/android/binder/process.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 268d78f8cfb3..82c34a93660e 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -30,7 +30,7 @@
sync::{
aref::ARef,
lock::{spinlock::SpinLockBackend, Guard},
- Arc, ArcBorrow, CondVar, CondVarTimeoutResult, Mutex, SpinLock, UniqueArc,
+ Arc, ArcBorrow, CondVar, CondVarTimeoutResult, SpinLock, UniqueArc,
},
task::Task,
uaccess::{UserSlice, UserSliceReader},
@@ -455,7 +455,7 @@ pub(crate) struct Process {
// Node references are in a different lock to avoid recursive acquisition when
// incrementing/decrementing a node in another process.
#[pin]
- node_refs: Mutex<ProcessNodeRefs>,
+ node_refs: SpinLock<ProcessNodeRefs>,
// Work node for deferred work item.
#[pin]
@@ -510,7 +510,7 @@ fn new(ctx: Arc<Context>, cred: ARef<Credential>) -> Result<Arc<Self>> {
cred,
inner <- kernel::new_spinlock!(ProcessInner::new(), "Process::inner"),
pages <- ShrinkablePageRange::new(&super::BINDER_SHRINKER),
- node_refs <- kernel::new_mutex!(ProcessNodeRefs::new(), "Process::node_refs"),
+ node_refs <- kernel::new_spinlock!(ProcessNodeRefs::new(), "Process::node_refs"),
freeze_wait <- kernel::new_condvar!("Process::freeze_wait"),
task: current.group_leader().into(),
defer_work <- kernel::new_work!("Process::defer_work"),
--
2.54.0.1064.gd145956f57-goog
next prev parent reply other threads:[~2026-06-09 9:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 9:33 [PATCH v2 0/6] rust_binder: update Process::node_refs to use SpinLock Alice Ryhl
2026-06-09 9:33 ` [PATCH v2 1/6] rust_binder: avoid allocating under node_refs for freeze listeners Alice Ryhl
2026-06-11 22:18 ` Matthew Maurer
2026-06-09 9:33 ` [PATCH v2 2/6] rust_binder: avoid dropping NodeRef in update_ref() under lock Alice Ryhl
2026-06-11 22:21 ` Matthew Maurer
2026-06-09 9:33 ` [PATCH v2 3/6] rust_binder: schedule NodeDeath outside of node_refs lock Alice Ryhl
2026-06-11 22:22 ` Matthew Maurer
2026-06-09 9:33 ` [PATCH v2 4/6] rust_binder: keep NodeDeath in NodeRefInfo during process cleanup Alice Ryhl
2026-06-11 23:16 ` Matthew Maurer
2026-06-09 9:33 ` [PATCH v2 5/6] rust_binder: avoid destructors in insert_or_update_handle() Alice Ryhl
2026-06-11 23:36 ` Matthew Maurer
2026-06-09 9:33 ` Alice Ryhl [this message]
2026-06-11 23:37 ` [PATCH v2 6/6] rust_binder: update Process::node_refs to use SpinLock Matthew Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609-binder-noderefs-spin-v2-6-eafde2ff376c@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox