summaryrefslogtreecommitdiff
path: root/drivers/android/binder/transaction.rs
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/android/binder/transaction.rs')
-rw-r--r--drivers/android/binder/transaction.rs30
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/android/binder/transaction.rs b/drivers/android/binder/transaction.rs
index 4bd3c0e417eb..75e6f5fbaaae 100644
--- a/drivers/android/binder/transaction.rs
+++ b/drivers/android/binder/transaction.rs
@@ -2,11 +2,11 @@
// Copyright (C) 2025 Google LLC.
-use core::sync::atomic::{AtomicBool, Ordering};
use kernel::{
prelude::*,
seq_file::SeqFile,
seq_print,
+ sync::atomic::{ordering::Relaxed, Atomic},
sync::{Arc, SpinLock},
task::Kuid,
time::{Instant, Monotonic},
@@ -24,6 +24,17 @@ use crate::{
BinderReturnWriter, DArc, DLArc, DTRWrap, DeliverToRead,
};
+use core::mem::offset_of;
+use kernel::bindings::rb_transaction_layout;
+pub(crate) const TRANSACTION_LAYOUT: rb_transaction_layout = rb_transaction_layout {
+ debug_id: offset_of!(Transaction, debug_id),
+ code: offset_of!(Transaction, code),
+ flags: offset_of!(Transaction, flags),
+ from_thread: offset_of!(Transaction, from),
+ to_proc: offset_of!(Transaction, to),
+ target_node: offset_of!(Transaction, target_node),
+};
+
#[pin_data(PinnedDrop)]
pub(crate) struct Transaction {
pub(crate) debug_id: usize,
@@ -33,7 +44,7 @@ pub(crate) struct Transaction {
pub(crate) to: Arc<Process>,
#[pin]
allocation: SpinLock<Option<Allocation>>,
- is_outstanding: AtomicBool,
+ is_outstanding: Atomic<bool>,
code: u32,
pub(crate) flags: u32,
data_size: usize,
@@ -105,7 +116,7 @@ impl Transaction {
offsets_size: trd.offsets_size as _,
data_address,
allocation <- kernel::new_spinlock!(Some(alloc.success()), "Transaction::new"),
- is_outstanding: AtomicBool::new(false),
+ is_outstanding: Atomic::new(false),
txn_security_ctx_off,
oneway_spam_detected,
start_time: Instant::now(),
@@ -145,7 +156,7 @@ impl Transaction {
offsets_size: trd.offsets_size as _,
data_address: alloc.ptr,
allocation <- kernel::new_spinlock!(Some(alloc.success()), "Transaction::new"),
- is_outstanding: AtomicBool::new(false),
+ is_outstanding: Atomic::new(false),
txn_security_ctx_off: None,
oneway_spam_detected,
start_time: Instant::now(),
@@ -215,8 +226,8 @@ impl Transaction {
pub(crate) fn set_outstanding(&self, to_process: &mut ProcessInner) {
// No race because this method is only called once.
- if !self.is_outstanding.load(Ordering::Relaxed) {
- self.is_outstanding.store(true, Ordering::Relaxed);
+ if !self.is_outstanding.load(Relaxed) {
+ self.is_outstanding.store(true, Relaxed);
to_process.add_outstanding_txn();
}
}
@@ -227,8 +238,8 @@ impl Transaction {
// destructor, which is guaranteed to not race with any other operations on the
// transaction. It also cannot race with `set_outstanding`, since submission happens
// before delivery.
- if self.is_outstanding.load(Ordering::Relaxed) {
- self.is_outstanding.store(false, Ordering::Relaxed);
+ if self.is_outstanding.load(Relaxed) {
+ self.is_outstanding.store(false, Relaxed);
self.to.drop_outstanding_txn();
}
}
@@ -249,6 +260,7 @@ impl Transaction {
if oneway {
if let Some(target_node) = self.target_node.clone() {
+ crate::trace::trace_transaction(false, &self, None);
if process_inner.is_frozen.is_frozen() {
process_inner.async_recv = true;
if self.flags & TF_UPDATE_TXN != 0 {
@@ -286,11 +298,13 @@ impl Transaction {
}
let res = if let Some(thread) = self.find_target_thread() {
+ crate::trace::trace_transaction(false, &self, Some(&thread.task));
match thread.push_work(self) {
PushWorkRes::Ok => Ok(()),
PushWorkRes::FailedDead(me) => Err((BinderError::new_dead(), me)),
}
} else {
+ crate::trace::trace_transaction(false, &self, None);
process_inner.push_work(self)
};
drop(process_inner);