Skip to content

Commit f8d2693

Browse files
Darksonngregkh
authored andcommitted
rust_binder: update Process::node_refs to use SpinLock
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. Reviewed-by: Matthew Maurer <mmaurer@google.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260615-binder-noderefs-spin-v3-6-3235f5a3e0a0@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 63b4af4 commit f8d2693

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/android/binder/process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use kernel::{
3030
sync::{
3131
aref::ARef,
3232
lock::{spinlock::SpinLockBackend, Guard},
33-
Arc, ArcBorrow, CondVar, CondVarTimeoutResult, Mutex, SpinLock, UniqueArc,
33+
Arc, ArcBorrow, CondVar, CondVarTimeoutResult, SpinLock, UniqueArc,
3434
},
3535
task::{Pid, Task},
3636
uaccess::{UserSlice, UserSliceReader},
@@ -455,7 +455,7 @@ pub(crate) struct Process {
455455
// Node references are in a different lock to avoid recursive acquisition when
456456
// incrementing/decrementing a node in another process.
457457
#[pin]
458-
node_refs: Mutex<ProcessNodeRefs>,
458+
node_refs: SpinLock<ProcessNodeRefs>,
459459

460460
// Work node for deferred work item.
461461
#[pin]
@@ -510,7 +510,7 @@ impl Process {
510510
cred,
511511
inner <- kernel::new_spinlock!(ProcessInner::new(), "Process::inner"),
512512
pages <- ShrinkablePageRange::new(&super::BINDER_SHRINKER),
513-
node_refs <- kernel::new_mutex!(ProcessNodeRefs::new(), "Process::node_refs"),
513+
node_refs <- kernel::new_spinlock!(ProcessNodeRefs::new(), "Process::node_refs"),
514514
freeze_wait <- kernel::new_condvar!("Process::freeze_wait"),
515515
task: current.group_leader().into(),
516516
defer_work <- kernel::new_work!("Process::defer_work"),

0 commit comments

Comments
 (0)