Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust_binder: add `command`/`return` tracepoints

Add Rust Binder `command` and `return` tracepoint declarations and
wire them in where BC commands are parsed and BR return codes are
emitted to userspace.

Signed-off-by: Mohamad Alsadhan <mo@sdhn.cc>
Link: https://patch.msgid.link/20260317-rust-binder-trace-v3-6-6fae4fbcf637@sdhn.cc
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mohamad Alsadhan and committed by
Greg Kroah-Hartman
8f348102 25917c05

+47
+32
drivers/android/binder/rust_binder_events.h
··· 145 145 __entry->debug_id, __entry->fd, __entry->offset) 146 146 ); 147 147 148 + TRACE_EVENT(binder_command, 149 + TP_PROTO(uint32_t cmd), 150 + TP_ARGS(cmd), 151 + TP_STRUCT__entry( 152 + __field(uint32_t, cmd) 153 + ), 154 + TP_fast_assign( 155 + __entry->cmd = cmd; 156 + ), 157 + TP_printk("cmd=0x%x %s", 158 + __entry->cmd, 159 + _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_command_strings) ? 160 + binder_command_strings[_IOC_NR(__entry->cmd)] : 161 + "unknown") 162 + ); 163 + 164 + TRACE_EVENT(binder_return, 165 + TP_PROTO(uint32_t cmd), 166 + TP_ARGS(cmd), 167 + TP_STRUCT__entry( 168 + __field(uint32_t, cmd) 169 + ), 170 + TP_fast_assign( 171 + __entry->cmd = cmd; 172 + ), 173 + TP_printk("cmd=0x%x %s", 174 + __entry->cmd, 175 + _IOC_NR(__entry->cmd) < ARRAY_SIZE(binder_return_strings) ? 176 + binder_return_strings[_IOC_NR(__entry->cmd)] : 177 + "unknown") 178 + ); 179 + 148 180 #endif /* _RUST_BINDER_TRACE_H */ 149 181 150 182 /* This part must be outside protection */
+1
drivers/android/binder/rust_binder_main.rs
··· 116 116 /// Write a return code back to user space. 117 117 /// Should be a `BR_` constant from [`defs`] e.g. [`defs::BR_TRANSACTION_COMPLETE`]. 118 118 fn write_code(&mut self, code: u32) -> Result { 119 + crate::trace::trace_return(code); 119 120 stats::GLOBAL_STATS.inc_br(code); 120 121 self.thread.process.stats.inc_br(code); 121 122 self.writer.write(&code)
+1
drivers/android/binder/thread.rs
··· 1370 1370 while reader.len() >= size_of::<u32>() && self.inner.lock().return_work.is_unused() { 1371 1371 let before = reader.len(); 1372 1372 let cmd = reader.read::<u32>()?; 1373 + crate::trace::trace_command(cmd); 1373 1374 GLOBAL_STATS.inc_bc(cmd); 1374 1375 self.process.stats.inc_bc(cmd); 1375 1376 match cmd {
+13
drivers/android/binder/trace.rs
··· 20 20 unsafe fn binder_transaction_received(t: rust_binder_transaction); 21 21 unsafe fn binder_transaction_fd_send(t_debug_id: c_int, fd: c_int, offset: usize); 22 22 unsafe fn binder_transaction_fd_recv(t_debug_id: c_int, fd: c_int, offset: usize); 23 + unsafe fn binder_command(cmd: u32); 24 + unsafe fn binder_return(ret: u32); 23 25 } 24 26 25 27 #[inline] ··· 91 89 pub(crate) fn trace_transaction_fd_recv(t_debug_id: usize, fd: u32, offset: usize) { 92 90 // SAFETY: This function is always safe to call. 93 91 unsafe { binder_transaction_fd_recv(t_debug_id as c_int, fd as c_int, offset) } 92 + } 93 + 94 + #[inline] 95 + pub(crate) fn trace_command(cmd: u32) { 96 + // SAFETY: This function is always safe to call. 97 + unsafe { binder_command(cmd) } 98 + } 99 + #[inline] 100 + pub(crate) fn trace_return(ret: u32) { 101 + // SAFETY: This function is always safe to call. 102 + unsafe { binder_return(ret) } 94 103 }