forked from mirrors/linux
		
	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 <christian.brauner@ubuntu.com> Signed-off-by: Hridya Valsaraju <hridya@google.com> Link: https://lore.kernel.org/r/20190903161655.107408-4-hridya@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									0e13e452da
								
							
						
					
					
						commit
						03e2e07e38
					
				
					 3 changed files with 53 additions and 29 deletions
				
			
		|  | @ -196,30 +196,8 @@ static inline void binder_stats_created(enum binder_stat_types type) | ||||||
| 	atomic_inc(&binder_stats.obj_created[type]); | 	atomic_inc(&binder_stats.obj_created[type]); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct binder_transaction_log_entry { | struct binder_transaction_log binder_transaction_log; | ||||||
| 	int debug_id; | struct binder_transaction_log binder_transaction_log_failed; | ||||||
| 	int debug_id_done; |  | ||||||
| 	int call_type; |  | ||||||
| 	int from_proc; |  | ||||||
| 	int from_thread; |  | ||||||
| 	int target_handle; |  | ||||||
| 	int to_proc; |  | ||||||
| 	int to_thread; |  | ||||||
| 	int to_node; |  | ||||||
| 	int data_size; |  | ||||||
| 	int offsets_size; |  | ||||||
| 	int return_error_line; |  | ||||||
| 	uint32_t return_error; |  | ||||||
| 	uint32_t return_error_param; |  | ||||||
| 	const char *context_name; |  | ||||||
| }; |  | ||||||
| struct binder_transaction_log { |  | ||||||
| 	atomic_t cur; |  | ||||||
| 	bool full; |  | ||||||
| 	struct binder_transaction_log_entry entry[32]; |  | ||||||
| }; |  | ||||||
| static struct binder_transaction_log binder_transaction_log; |  | ||||||
| static struct binder_transaction_log binder_transaction_log_failed; |  | ||||||
| 
 | 
 | ||||||
| static struct binder_transaction_log_entry *binder_transaction_log_add( | static struct binder_transaction_log_entry *binder_transaction_log_add( | ||||||
| 	struct binder_transaction_log *log) | 	struct binder_transaction_log *log) | ||||||
|  | @ -6018,7 +5996,7 @@ static void print_binder_transaction_log_entry(struct seq_file *m, | ||||||
| 			"\n" : " (incomplete)\n"); | 			"\n" : " (incomplete)\n"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int transaction_log_show(struct seq_file *m, void *unused) | int binder_transaction_log_show(struct seq_file *m, void *unused) | ||||||
| { | { | ||||||
| 	struct binder_transaction_log *log = m->private; | 	struct binder_transaction_log *log = m->private; | ||||||
| 	unsigned int log_cur = atomic_read(&log->cur); | 	unsigned int log_cur = atomic_read(&log->cur); | ||||||
|  | @ -6050,8 +6028,6 @@ const struct file_operations binder_fops = { | ||||||
| 	.release = binder_release, | 	.release = binder_release, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| DEFINE_SHOW_ATTRIBUTE(transaction_log); |  | ||||||
| 
 |  | ||||||
| static int __init init_binder_device(const char *name) | static int __init init_binder_device(const char *name) | ||||||
| { | { | ||||||
| 	int ret; | 	int ret; | ||||||
|  | @ -6120,12 +6096,12 @@ static int __init binder_init(void) | ||||||
| 				    0444, | 				    0444, | ||||||
| 				    binder_debugfs_dir_entry_root, | 				    binder_debugfs_dir_entry_root, | ||||||
| 				    &binder_transaction_log, | 				    &binder_transaction_log, | ||||||
| 				    &transaction_log_fops); | 				    &binder_transaction_log_fops); | ||||||
| 		debugfs_create_file("failed_transaction_log", | 		debugfs_create_file("failed_transaction_log", | ||||||
| 				    0444, | 				    0444, | ||||||
| 				    binder_debugfs_dir_entry_root, | 				    binder_debugfs_dir_entry_root, | ||||||
| 				    &binder_transaction_log_failed, | 				    &binder_transaction_log_failed, | ||||||
| 				    &transaction_log_fops); | 				    &binder_transaction_log_fops); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) && | 	if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) && | ||||||
|  |  | ||||||
|  | @ -65,4 +65,34 @@ DEFINE_SHOW_ATTRIBUTE(binder_state); | ||||||
| 
 | 
 | ||||||
| int binder_transactions_show(struct seq_file *m, void *unused); | int binder_transactions_show(struct seq_file *m, void *unused); | ||||||
| DEFINE_SHOW_ATTRIBUTE(binder_transactions); | DEFINE_SHOW_ATTRIBUTE(binder_transactions); | ||||||
|  | 
 | ||||||
|  | int binder_transaction_log_show(struct seq_file *m, void *unused); | ||||||
|  | DEFINE_SHOW_ATTRIBUTE(binder_transaction_log); | ||||||
|  | 
 | ||||||
|  | struct binder_transaction_log_entry { | ||||||
|  | 	int debug_id; | ||||||
|  | 	int debug_id_done; | ||||||
|  | 	int call_type; | ||||||
|  | 	int from_proc; | ||||||
|  | 	int from_thread; | ||||||
|  | 	int target_handle; | ||||||
|  | 	int to_proc; | ||||||
|  | 	int to_thread; | ||||||
|  | 	int to_node; | ||||||
|  | 	int data_size; | ||||||
|  | 	int offsets_size; | ||||||
|  | 	int return_error_line; | ||||||
|  | 	uint32_t return_error; | ||||||
|  | 	uint32_t return_error_param; | ||||||
|  | 	const char *context_name; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | struct binder_transaction_log { | ||||||
|  | 	atomic_t cur; | ||||||
|  | 	bool full; | ||||||
|  | 	struct binder_transaction_log_entry entry[32]; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | extern struct binder_transaction_log binder_transaction_log; | ||||||
|  | extern struct binder_transaction_log binder_transaction_log_failed; | ||||||
| #endif /* _LINUX_BINDER_INTERNAL_H */ | #endif /* _LINUX_BINDER_INTERNAL_H */ | ||||||
|  |  | ||||||
|  | @ -630,6 +630,24 @@ static int init_binder_logs(struct super_block *sb) | ||||||
| 
 | 
 | ||||||
| 	dentry = binderfs_create_file(binder_logs_root_dir, "transactions", | 	dentry = binderfs_create_file(binder_logs_root_dir, "transactions", | ||||||
| 				      &binder_transactions_fops, NULL); | 				      &binder_transactions_fops, NULL); | ||||||
|  | 	if (IS_ERR(dentry)) { | ||||||
|  | 		ret = PTR_ERR(dentry); | ||||||
|  | 		goto out; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	dentry = binderfs_create_file(binder_logs_root_dir, | ||||||
|  | 				      "transaction_log", | ||||||
|  | 				      &binder_transaction_log_fops, | ||||||
|  | 				      &binder_transaction_log); | ||||||
|  | 	if (IS_ERR(dentry)) { | ||||||
|  | 		ret = PTR_ERR(dentry); | ||||||
|  | 		goto out; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	dentry = binderfs_create_file(binder_logs_root_dir, | ||||||
|  | 				      "failed_transaction_log", | ||||||
|  | 				      &binder_transaction_log_fops, | ||||||
|  | 				      &binder_transaction_log_failed); | ||||||
| 	if (IS_ERR(dentry)) | 	if (IS_ERR(dentry)) | ||||||
| 		ret = PTR_ERR(dentry); | 		ret = PTR_ERR(dentry); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Hridya Valsaraju
						Hridya Valsaraju