From e6cf4b4e365a0d8274d00e3f8ea2331cd70c8ec4 Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Sun, 27 Jul 2025 18:29:08 +0000 Subject: [PATCH] BACKPORT: FROMGIT: binder: add tracepoint for netlink reports Add a tracepoint to capture the same details that are being sent through the generic netlink interface during transaction failures. This provides a useful debugging tool to observe the events independently from the netlink listeners. Signed-off-by: Carlos Llamas Link: https://lore.kernel.org/r/20250727182932.2499194-6-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman Bug: 372832477 (cherry picked from commit 8a61a53b07f23ff12330086b293b6b492d35b8a0 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-next) Change-Id: I5185383180787d1a237b8f583306055081a9f0d9 [cmllamas: fixed missing t->is_reply] Signed-off-by: Carlos Llamas --- drivers/android/binder.c | 2 ++ drivers/android/binder_trace.h | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 136c259cd44a..1479525e2913 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -3211,6 +3211,8 @@ static void binder_netlink_report(struct binder_proc *proc, BINDER_NLGRP_REPORT)) return; + trace_binder_netlink_report(context, t, data_size, error, is_reply); + skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!skb) return; diff --git a/drivers/android/binder_trace.h b/drivers/android/binder_trace.h index f27fd85ba33d..1742ea81a497 100644 --- a/drivers/android/binder_trace.h +++ b/drivers/android/binder_trace.h @@ -447,6 +447,44 @@ TRACE_EVENT(binder_return, "unknown") ); +TRACE_EVENT(binder_netlink_report, + TP_PROTO(const char *context, + struct binder_transaction *t, + u32 data_size, + u32 error, + int is_reply), + TP_ARGS(context, t, data_size, error, is_reply), + TP_STRUCT__entry( + __field(const char *, context) + __field(u32, error) + __field(int, from_pid) + __field(int, from_tid) + __field(int, to_pid) + __field(int, to_tid) + __field(bool, is_reply) + __field(unsigned int, flags) + __field(unsigned int, code) + __field(size_t, data_size) + ), + TP_fast_assign( + __entry->context = context; + __entry->error = error; + __entry->from_pid = t->from_pid; + __entry->from_tid = t->from_tid; + __entry->to_pid = t->to_proc ? t->to_proc->pid : 0; + __entry->to_tid = t->to_thread ? t->to_thread->pid : 0; + __entry->is_reply = is_reply; + __entry->flags = t->flags; + __entry->code = t->code; + __entry->data_size = data_size; + ), + TP_printk("from %d:%d to %d:%d context=%s error=%d is_reply=%d flags=0x%x code=0x%x size=%zu", + __entry->from_pid, __entry->from_tid, + __entry->to_pid, __entry->to_tid, + __entry->context, __entry->error, __entry->is_reply, + __entry->flags, __entry->code, __entry->data_size) +); + #endif /* _BINDER_TRACE_H */ #undef TRACE_INCLUDE_PATH