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 `wait_for_work` tracepoint

Add the Rust Binder `wait_for_work` tracepoint declaration and wire
it into the thread read path before selecting the work source.

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

authored by

Mohamad Alsadhan and committed by
Greg Kroah-Hartman
2335167a be3953bb

+34 -2
+18
drivers/android/binder/rust_binder_events.h
··· 51 51 DEFINE_RBINDER_FUNCTION_RETURN_EVENT(binder_read_done); 52 52 DEFINE_RBINDER_FUNCTION_RETURN_EVENT(binder_write_done); 53 53 54 + TRACE_EVENT(binder_wait_for_work, 55 + TP_PROTO(bool proc_work, bool transaction_stack, bool thread_todo), 56 + TP_ARGS(proc_work, transaction_stack, thread_todo), 57 + TP_STRUCT__entry( 58 + __field(bool, proc_work) 59 + __field(bool, transaction_stack) 60 + __field(bool, thread_todo) 61 + ), 62 + TP_fast_assign( 63 + __entry->proc_work = proc_work; 64 + __entry->transaction_stack = transaction_stack; 65 + __entry->thread_todo = thread_todo; 66 + ), 67 + TP_printk("proc_work=%d transaction_stack=%d thread_todo=%d", 68 + __entry->proc_work, __entry->transaction_stack, 69 + __entry->thread_todo) 70 + ); 71 + 54 72 TRACE_EVENT(binder_transaction, 55 73 TP_PROTO(bool reply, rust_binder_transaction t, struct task_struct *thread), 56 74 TP_ARGS(reply, t, thread),
+9 -2
drivers/android/binder/thread.rs
··· 1437 1437 UserSlice::new(UserPtr::from_addr(read_start as _), read_len as _).writer(), 1438 1438 self, 1439 1439 ); 1440 - let (in_pool, use_proc_queue) = { 1440 + let (in_pool, has_transaction, thread_todo, use_proc_queue) = { 1441 1441 let inner = self.inner.lock(); 1442 - (inner.is_looper(), inner.should_use_process_work_queue()) 1442 + ( 1443 + inner.is_looper(), 1444 + inner.current_transaction.is_some(), 1445 + !inner.work_list.is_empty(), 1446 + inner.should_use_process_work_queue(), 1447 + ) 1443 1448 }; 1449 + 1450 + crate::trace::trace_wait_for_work(use_proc_queue, has_transaction, thread_todo); 1444 1451 1445 1452 let getter = if use_proc_queue { 1446 1453 Self::get_work
+7
drivers/android/binder/trace.rs
··· 15 15 unsafe fn binder_ioctl_done(ret: c_int); 16 16 unsafe fn binder_read_done(ret: c_int); 17 17 unsafe fn binder_write_done(ret: c_int); 18 + unsafe fn binder_wait_for_work(proc_work: bool, transaction_stack: bool, thread_todo: bool); 18 19 unsafe fn binder_transaction(reply: bool, t: rust_binder_transaction, thread: *mut task_struct); 19 20 } 20 21 ··· 52 51 pub(crate) fn trace_write_done(ret: Result) { 53 52 // SAFETY: Always safe to call. 54 53 unsafe { binder_write_done(to_errno(ret)) } 54 + } 55 + 56 + #[inline] 57 + pub(crate) fn trace_wait_for_work(proc_work: bool, transaction_stack: bool, thread_todo: bool) { 58 + // SAFETY: Always safe to call. 59 + unsafe { binder_wait_for_work(proc_work, transaction_stack, thread_todo) } 55 60 } 56 61 57 62 #[inline]