Skip to content

Commit 03e2e07

Browse files
Hridya Valsarajugregkh
authored andcommitted
binder: Make transaction_log available in binderfs
Currently, the binder transaction log files 'transaction_log' and 'failed_transaction_log' live in debugfs at the following locations: /sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/transaction_log This patch makes these files also available in a binderfs instance mounted with the mount option "stats=global". It does not affect the presence of these files in debugfs. If a binderfs instance is mounted at path /dev/binderfs, the location of these files will be as follows: /dev/binderfs/binder_logs/failed_transaction_log /dev/binderfs/binder_logs/transaction_log This change provides an alternate option to access these files when debugfs is not mounted. Acked-by: Christian Brauner <[email protected]> Signed-off-by: Hridya Valsaraju <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0e13e45 commit 03e2e07

File tree

3 files changed

+53
-29
lines changed

3 files changed

+53
-29
lines changed

drivers/android/binder.c

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -196,30 +196,8 @@ static inline void binder_stats_created(enum binder_stat_types type)
196196
atomic_inc(&binder_stats.obj_created[type]);
197197
}
198198

199-
struct binder_transaction_log_entry {
200-
int debug_id;
201-
int debug_id_done;
202-
int call_type;
203-
int from_proc;
204-
int from_thread;
205-
int target_handle;
206-
int to_proc;
207-
int to_thread;
208-
int to_node;
209-
int data_size;
210-
int offsets_size;
211-
int return_error_line;
212-
uint32_t return_error;
213-
uint32_t return_error_param;
214-
const char *context_name;
215-
};
216-
struct binder_transaction_log {
217-
atomic_t cur;
218-
bool full;
219-
struct binder_transaction_log_entry entry[32];
220-
};
221-
static struct binder_transaction_log binder_transaction_log;
222-
static struct binder_transaction_log binder_transaction_log_failed;
199+
struct binder_transaction_log binder_transaction_log;
200+
struct binder_transaction_log binder_transaction_log_failed;
223201

224202
static struct binder_transaction_log_entry *binder_transaction_log_add(
225203
struct binder_transaction_log *log)
@@ -6018,7 +5996,7 @@ static void print_binder_transaction_log_entry(struct seq_file *m,
60185996
"\n" : " (incomplete)\n");
60195997
}
60205998

6021-
static int transaction_log_show(struct seq_file *m, void *unused)
5999+
int binder_transaction_log_show(struct seq_file *m, void *unused)
60226000
{
60236001
struct binder_transaction_log *log = m->private;
60246002
unsigned int log_cur = atomic_read(&log->cur);
@@ -6050,8 +6028,6 @@ const struct file_operations binder_fops = {
60506028
.release = binder_release,
60516029
};
60526030

6053-
DEFINE_SHOW_ATTRIBUTE(transaction_log);
6054-
60556031
static int __init init_binder_device(const char *name)
60566032
{
60576033
int ret;
@@ -6120,12 +6096,12 @@ static int __init binder_init(void)
61206096
0444,
61216097
binder_debugfs_dir_entry_root,
61226098
&binder_transaction_log,
6123-
&transaction_log_fops);
6099+
&binder_transaction_log_fops);
61246100
debugfs_create_file("failed_transaction_log",
61256101
0444,
61266102
binder_debugfs_dir_entry_root,
61276103
&binder_transaction_log_failed,
6128-
&transaction_log_fops);
6104+
&binder_transaction_log_fops);
61296105
}
61306106

61316107
if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&

drivers/android/binder_internal.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,34 @@ DEFINE_SHOW_ATTRIBUTE(binder_state);
6565

6666
int binder_transactions_show(struct seq_file *m, void *unused);
6767
DEFINE_SHOW_ATTRIBUTE(binder_transactions);
68+
69+
int binder_transaction_log_show(struct seq_file *m, void *unused);
70+
DEFINE_SHOW_ATTRIBUTE(binder_transaction_log);
71+
72+
struct binder_transaction_log_entry {
73+
int debug_id;
74+
int debug_id_done;
75+
int call_type;
76+
int from_proc;
77+
int from_thread;
78+
int target_handle;
79+
int to_proc;
80+
int to_thread;
81+
int to_node;
82+
int data_size;
83+
int offsets_size;
84+
int return_error_line;
85+
uint32_t return_error;
86+
uint32_t return_error_param;
87+
const char *context_name;
88+
};
89+
90+
struct binder_transaction_log {
91+
atomic_t cur;
92+
bool full;
93+
struct binder_transaction_log_entry entry[32];
94+
};
95+
96+
extern struct binder_transaction_log binder_transaction_log;
97+
extern struct binder_transaction_log binder_transaction_log_failed;
6898
#endif /* _LINUX_BINDER_INTERNAL_H */

drivers/android/binderfs.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,24 @@ static int init_binder_logs(struct super_block *sb)
630630

631631
dentry = binderfs_create_file(binder_logs_root_dir, "transactions",
632632
&binder_transactions_fops, NULL);
633+
if (IS_ERR(dentry)) {
634+
ret = PTR_ERR(dentry);
635+
goto out;
636+
}
637+
638+
dentry = binderfs_create_file(binder_logs_root_dir,
639+
"transaction_log",
640+
&binder_transaction_log_fops,
641+
&binder_transaction_log);
642+
if (IS_ERR(dentry)) {
643+
ret = PTR_ERR(dentry);
644+
goto out;
645+
}
646+
647+
dentry = binderfs_create_file(binder_logs_root_dir,
648+
"failed_transaction_log",
649+
&binder_transaction_log_fops,
650+
&binder_transaction_log_failed);
633651
if (IS_ERR(dentry))
634652
ret = PTR_ERR(dentry);
635653

0 commit comments

Comments
 (0)