Binder: Add async from to transaction record
authorChuang Zhang <zhangchuang3@xiaomi.com>
Mon, 24 Apr 2023 11:05:15 +0000 (19:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 May 2023 11:38:12 +0000 (20:38 +0900)
This commit adds support for getting the pid and tid information of
the sender for asynchronous transfers in binderfs transfer records.
In previous versions, it was not possible to obtain this information
from the transfer records. While this information may not be necessary
for all use cases, it can be useful in some scenarios.

Signed-off-by: Chuang Zhang <zhangchuang3@xiaomi.com>
Acked-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/0c1e8bd37c68dd1518bb737b06b768cde9659386.1682333709.git.zhangchuang3@xiaomi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c
drivers/android/binder_internal.h

index b6413652906ec1ed21c9b3cd80dfe691f3611cf6..6674619845e03df0b8544785f4044ae7673a2d59 100644 (file)
@@ -3172,6 +3172,8 @@ static void binder_transaction(struct binder_proc *proc,
                t->from = thread;
        else
                t->from = NULL;
+       t->from_pid = proc->pid;
+       t->from_tid = thread->pid;
        t->sender_euid = task_euid(proc->tsk);
        t->to_proc = target_proc;
        t->to_thread = target_thread;
@@ -5940,8 +5942,8 @@ static void print_binder_transaction_ilocked(struct seq_file *m,
        seq_printf(m,
                   "%s %d: %pK from %d:%d to %d:%d code %x flags %x pri %ld r%d elapsed %lldms",
                   prefix, t->debug_id, t,
-                  t->from ? t->from->proc->pid : 0,
-                  t->from ? t->from->pid : 0,
+                  t->from_pid,
+                  t->from_tid,
                   to_proc ? to_proc->pid : 0,
                   t->to_thread ? t->to_thread->pid : 0,
                   t->code, t->flags, t->priority, t->need_reply,
index 92e64007f2b0aee28048dabec5c3856deb615fec..7270d4d22207021007af32638b79b0e48bdd313c 100644 (file)
@@ -515,6 +515,8 @@ struct binder_transaction {
        int debug_id;
        struct binder_work work;
        struct binder_thread *from;
+       pid_t from_pid;
+       pid_t from_tid;
        struct binder_transaction *from_parent;
        struct binder_proc *to_proc;
        struct binder_thread *to_thread;