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 fd translation tracepoints

Add Rust Binder tracepoint declarations for both `transaction_fd_send`
and `transaction_fd_recv`. Also, wire in the corresponding trace calls
where fd objects are serialised/deserialised.

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

authored by

Mohamad Alsadhan and committed by
Greg Kroah-Hartman
25917c05 caf3719f

+54
+1
drivers/android/binder/allocation.rs
··· 205 205 let res = FileDescriptorReservation::get_unused_fd_flags(bindings::O_CLOEXEC)?; 206 206 let fd = res.reserved_fd(); 207 207 self.write::<u32>(file_info.buffer_offset, &fd)?; 208 + crate::trace::trace_transaction_fd_recv(self.debug_id, fd, file_info.buffer_offset); 208 209 209 210 reservations.push( 210 211 Reservation {
+5
drivers/android/binder/rust_binder.h
··· 99 99 return *(size_t *) (t + RUST_BINDER_LAYOUT.n.debug_id); 100 100 } 101 101 102 + static inline binder_uintptr_t rust_binder_node_ptr(rust_binder_node t) 103 + { 104 + return *(binder_uintptr_t *) (t + RUST_BINDER_LAYOUT.n.ptr); 105 + } 106 + 102 107 #endif
+34
drivers/android/binder/rust_binder_events.h
··· 111 111 TP_printk("transaction=%d", __entry->debug_id) 112 112 ); 113 113 114 + TRACE_EVENT(binder_transaction_fd_send, 115 + TP_PROTO(int t_debug_id, int fd, size_t offset), 116 + TP_ARGS(t_debug_id, fd, offset), 117 + TP_STRUCT__entry( 118 + __field(int, debug_id) 119 + __field(int, fd) 120 + __field(size_t, offset) 121 + ), 122 + TP_fast_assign( 123 + __entry->debug_id = t_debug_id; 124 + __entry->fd = fd; 125 + __entry->offset = offset; 126 + ), 127 + TP_printk("transaction=%d src_fd=%d offset=%zu", 128 + __entry->debug_id, __entry->fd, __entry->offset) 129 + ); 130 + 131 + TRACE_EVENT(binder_transaction_fd_recv, 132 + TP_PROTO(int t_debug_id, int fd, size_t offset), 133 + TP_ARGS(t_debug_id, fd, offset), 134 + TP_STRUCT__entry( 135 + __field(int, debug_id) 136 + __field(int, fd) 137 + __field(size_t, offset) 138 + ), 139 + TP_fast_assign( 140 + __entry->debug_id = t_debug_id; 141 + __entry->fd = fd; 142 + __entry->offset = offset; 143 + ), 144 + TP_printk("transaction=%d dest_fd=%d offset=%zu", 145 + __entry->debug_id, __entry->fd, __entry->offset) 146 + ); 147 + 114 148 #endif /* _RUST_BINDER_TRACE_H */ 115 149 116 150 /* This part must be outside protection */
+1
drivers/android/binder/thread.rs
··· 712 712 core::mem::offset_of!(uapi::binder_fd_object, __bindgen_anon_1.fd); 713 713 714 714 let field_offset = offset + FD_FIELD_OFFSET; 715 + crate::trace::trace_transaction_fd_send(view.alloc.debug_id, fd, field_offset); 715 716 716 717 view.alloc.info_add_fd(file, field_offset, false)?; 717 718 }
+13
drivers/android/binder/trace.rs
··· 18 18 unsafe fn binder_wait_for_work(proc_work: bool, transaction_stack: bool, thread_todo: bool); 19 19 unsafe fn binder_transaction(reply: bool, t: rust_binder_transaction, thread: *mut task_struct); 20 20 unsafe fn binder_transaction_received(t: rust_binder_transaction); 21 + unsafe fn binder_transaction_fd_send(t_debug_id: c_int, fd: c_int, offset: usize); 22 + unsafe fn binder_transaction_fd_recv(t_debug_id: c_int, fd: c_int, offset: usize); 21 23 } 22 24 23 25 #[inline] ··· 78 76 pub(crate) fn trace_transaction_received(t: &Transaction) { 79 77 // SAFETY: The raw transaction is valid for the duration of this call. 80 78 unsafe { binder_transaction_received(raw_transaction(t)) } 79 + } 80 + 81 + #[inline] 82 + pub(crate) fn trace_transaction_fd_send(t_debug_id: usize, fd: u32, offset: usize) { 83 + // SAFETY: This function is always safe to call. 84 + unsafe { binder_transaction_fd_send(t_debug_id as c_int, fd as c_int, offset) } 85 + } 86 + #[inline] 87 + pub(crate) fn trace_transaction_fd_recv(t_debug_id: usize, fd: u32, offset: usize) { 88 + // SAFETY: This function is always safe to call. 89 + unsafe { binder_transaction_fd_recv(t_debug_id as c_int, fd as c_int, offset) } 81 90 }