mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
rust_binder: add transaction buffer tracepoints
Add `binder_transaction_alloc_buf`, `binder_transaction_buffer_release`, and `binder_transaction_failed_buffer_release`, mirroring C Binder's `binder_buffer_class` events of the same names and following android's fork for the function signatures. Link: https://github.com/Rust-for-Linux/linux/issues/1226 Suggested-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Sagar Taunk <sagartaunk@proton.me> Link: https://patch.msgid.link/20260927125622.676342-2-sagartaunk@proton.me Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2fcc8b9687
commit
710da9d05b
|
|
@ -177,6 +177,48 @@ TRACE_EVENT(binder_return,
|
|||
"unknown")
|
||||
);
|
||||
|
||||
|
||||
TRACE_EVENT(binder_transaction_alloc_buf,
|
||||
TP_PROTO(int debug_id, size_t data_size, size_t offsets_size, size_t extra_buffers_size),
|
||||
TP_ARGS(debug_id, data_size, offsets_size, extra_buffers_size),
|
||||
TP_STRUCT__entry(
|
||||
__field(int, debug_id)
|
||||
__field(size_t, data_size)
|
||||
__field(size_t, offsets_size)
|
||||
__field(size_t, extra_buffers_size)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->debug_id = debug_id;
|
||||
__entry->data_size = data_size;
|
||||
__entry->offsets_size = offsets_size;
|
||||
__entry->extra_buffers_size = extra_buffers_size;
|
||||
),
|
||||
TP_printk("transaction=%d data_size=%zd offsets_size=%zd extra_buffers_size=%zd",
|
||||
__entry->debug_id, __entry->data_size, __entry->offsets_size,
|
||||
__entry->extra_buffers_size)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(binder_buffer_release_class,
|
||||
TP_PROTO(int debug_id),
|
||||
TP_ARGS(debug_id),
|
||||
TP_STRUCT__entry(
|
||||
__field(int, debug_id)
|
||||
),
|
||||
TP_fast_assign(
|
||||
__entry->debug_id = debug_id;
|
||||
),
|
||||
TP_printk("transaction=%d", __entry->debug_id)
|
||||
);
|
||||
|
||||
#define DEFINE_RBINDER_FUNCTION_BUFFER_EVENT(name) \
|
||||
DEFINE_EVENT(binder_buffer_release_class, name, \
|
||||
TP_PROTO(int debug_id), \
|
||||
TP_ARGS(debug_id))
|
||||
|
||||
DEFINE_RBINDER_FUNCTION_BUFFER_EVENT(binder_transaction_buffer_release);
|
||||
DEFINE_RBINDER_FUNCTION_BUFFER_EVENT(binder_transaction_failed_buffer_release);
|
||||
DEFINE_RBINDER_FUNCTION_BUFFER_EVENT(binder_transaction_update_buffer_release);
|
||||
|
||||
#endif /* _RUST_BINDER_TRACE_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@
|
|||
unsafe fn binder_transaction_fd_recv(t_debug_id: c_int, fd: c_int, offset: usize);
|
||||
unsafe fn binder_command(cmd: u32);
|
||||
unsafe fn binder_return(ret: u32);
|
||||
unsafe fn binder_transaction_alloc_buf(
|
||||
debug_id: c_int,data_size: usize, offset_size: usize, extra_buffers_size: usize);
|
||||
unsafe fn binder_transaction_buffer_release(debug_id: c_int);
|
||||
unsafe fn binder_transaction_failed_buffer_release(debug_id: c_int);
|
||||
unsafe fn binder_transaction_update_buffer_release(debug_id: c_int);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -105,3 +110,35 @@ pub(crate) fn trace_return(ret: u32) {
|
|||
// SAFETY: This function is always safe to call.
|
||||
unsafe { binder_return(ret) }
|
||||
}
|
||||
#[inline]
|
||||
pub(crate) fn trace_transaction_alloc_buf(
|
||||
debug_id: usize,
|
||||
data_size: usize,
|
||||
offset_size: usize,
|
||||
extra_buffers_size: usize,
|
||||
) {
|
||||
// SAFETY: The `data` pointer is valid.
|
||||
unsafe {
|
||||
binder_transaction_alloc_buf(
|
||||
debug_id as c_int,
|
||||
data_size,
|
||||
offset_size,
|
||||
extra_buffers_size,
|
||||
)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub(crate) fn trace_transaction_buffer_release(debug_id: usize) {
|
||||
// SAFETY: This function is always safe to call.
|
||||
unsafe { binder_transaction_buffer_release(debug_id as c_int) }
|
||||
}
|
||||
#[inline]
|
||||
pub(crate) fn trace_transaction_failed_buffer_release(debug_id: usize) {
|
||||
// SAFETY: This function is always safe to call.
|
||||
unsafe { binder_transaction_failed_buffer_release(debug_id as c_int) }
|
||||
}
|
||||
#[inline]
|
||||
pub(crate) fn trace_transaction_update_buffer_release(debug_id: usize) {
|
||||
// SAFETY: This function is always safe to call.
|
||||
unsafe { binder_transaction_update_buffer_release(debug_id as c_int) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user