[PATCH v2 6/7] rust_binder: Implement BINDER_DEBUG_DEATH_NOTIFICATION

From: Jahnavi MN via B4 Relay

Date: Fri Jul 10 2026 - 10:40:13 EST


From: Jahnavi MN <jahnavimn@xxxxxxxxxx>

This adds dynamic debug logs for:
- Memory allocation (OOM) failures when requesting
death notifications
- Registration and cancellation lifecycle events
(BC_REQUEST / BC_CLEAR)
- Delivery of death notification events to userspace
(BR_DEAD_BINDER)

Signed-off-by: Jahnavi MN <jahnavimn@xxxxxxxxxx>
---
drivers/android/binder/node.rs | 5 +++++
drivers/android/binder/process.rs | 14 ++++++++++++++
2 files changed, 19 insertions(+)

diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs
index dfad3697f672..898412cfddd9 100644
--- a/drivers/android/binder/node.rs
+++ b/drivers/android/binder/node.rs
@@ -1113,6 +1113,11 @@ fn do_work(
// We're still holding the inner lock, so it cannot be aborted while we insert it into
// the delivered list.
process_inner.death_delivered(self.clone());
+ binder_debug!(
+ DeathNotification,
+ "sending death notification, cookie {:016x}",
+ cookie
+ );
BR_DEAD_BINDER
};

diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index db2b0230d19f..b1f1207ee868 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -1267,6 +1267,10 @@ pub(crate) fn request_death(
// Queue BR_ERROR if we can't allocate memory for the death notification.
let death = UniqueArc::new_uninit(GFP_KERNEL).inspect_err(|_| {
thread.push_return_work(BR_ERROR);
+ binder_debug!(
+ DeathNotification,
+ "BC_REQUEST_DEATH_NOTIFICATION failed due to memory allocation failure"
+ );
})?;
let mut refs = self.node_refs.lock();
let Some(info) = refs.by_handle.get_mut(&handle) else {
@@ -1310,6 +1314,11 @@ pub(crate) fn request_death(
info.node_ref().node.add_death(death, &mut owner_inner);
}
}
+ binder_debug!(
+ DeathNotification,
+ "BC_REQUEST_DEATH_NOTIFICATION handle {handle} cookie {:016x}",
+ cookie
+ );
Ok(())
}

@@ -1353,6 +1362,11 @@ pub(crate) fn clear_death(&self, reader: &mut UserSliceReader, thread: &Thread)
}
}

+ binder_debug!(
+ DeathNotification,
+ "BC_CLEAR_DEATH_NOTIFICATION handle {handle} cookie {:016x}",
+ cookie
+ );
Ok(())
}


--
2.55.0.795.g602f6c329a-goog