Skip to contentSkip to conversation

Add binder state and statistics to binderfs

PATCH In review Hridya Valsaraju 4 participants 13 messages Sep 3, 2019 – Sep 27, 2019 Android drivers

lore
Share & tools
lore
#0 lore raw

v3 cover Add binder state and statistics to binderfs

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Hridya Valsaraju (4):
binder: add a mount option to show global stats
binder: Add stats, state and transactions files
binder: Make transaction_log available in binderfs
binder: Add binder_proc logging to binderfs

 drivers/android/binder.c          |  95 ++++++-----
 drivers/android/binder_internal.h |  84 ++++++++++
 drivers/android/binderfs.c        | 255 ++++++++++++++++++++++++++----
 3 files changed, 362 insertions(+), 72 deletions(-)
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#1 lore raw

PATCH v3 1/4 binder: add a mount option to show global stats

Currently, all binder state and statistics live in debugfs. We need this information even when debugfs is not mounted. This patch adds the mount option 'stats' to enable a binderfs instance to have binder debug information present in the same. 'stats=global' will enable the global binder statistics. In the future, 'stats=local' will enable binder statistics local to the binderfs instance. The two modes 'global' and 'local' will be mutually exclusive. 'stats=global' option is only available for a binderfs instance mounted in the initial user namespace. An attempt to use the option to mount a binderfs instance in another user namespace will return an EPERM error.

---

Changes in v2:
- Improve error check in binderfs_parse_mount_opts() as per Greg Kroah-Hartman.
- Change pr_info() log before failure to pr_err() as per Greg Kroah-Hartman.

 drivers/android/binderfs.c | 45 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)
drivers/android/binderfs.c +43 -2
index cc2e71576396..7045bfe5b52b 100644
@@ -51,18 +51,27 @@ static DEFINE_IDA(binderfs_minors);
 /**
  * binderfs_mount_opts - mount options for binderfs
  * @max: maximum number of allocatable binderfs binder devices
+ * @stats_mode: enable binder stats in binderfs.
  */
 struct binderfs_mount_opts {
 	int max;
+	int stats_mode;
 };
 
 enum {
 	Opt_max,
+	Opt_stats_mode,
 	Opt_err
 };
 
+enum binderfs_stats_mode {
+	STATS_NONE,
+	STATS_GLOBAL,
+};
+
 static const match_table_t tokens = {
 	{ Opt_max, "max=%d" },
+	{ Opt_stats_mode, "stats=%s" },
 	{ Opt_err, NULL     }
 };
 
@@ -290,8 +299,9 @@ static void binderfs_evict_inode(struct inode *inode)
 static int binderfs_parse_mount_opts(char *data,
 				     struct binderfs_mount_opts *opts)
 {
-	char *p;
+	char *p, *stats;
 	opts->max = BINDERFS_MAX_MINOR;
+	opts->stats_mode = STATS_NONE;
 
 	while ((p = strsep(&data, ",")) != NULL) {
 		substring_t args[MAX_OPT_ARGS];
@@ -311,6 +321,22 @@ static int binderfs_parse_mount_opts(char *data,
 
 			opts->max = max_devices;
 			break;
+		case Opt_stats_mode:
+			if (!capable(CAP_SYS_ADMIN))
+				return -EINVAL;
+
+			stats = match_strdup(&args[0]);
+			if (!stats)
+				return -ENOMEM;
+
+			if (strcmp(stats, "global") != 0) {
+				kfree(stats);
+				return -EINVAL;
+			}
+
+			opts->stats_mode = STATS_GLOBAL;
+			kfree(stats);
+			break;
 		default:
 			pr_err("Invalid mount options\n");
 			return -EINVAL;
@@ -322,8 +348,21 @@ static int binderfs_parse_mount_opts(char *data,
 
 static int binderfs_remount(struct super_block *sb, int *flags, char *data)
 {
+	int prev_stats_mode, ret;
 	struct binderfs_info *info = sb->s_fs_info;
-	return binderfs_parse_mount_opts(data, &info->mount_opts);
+
+	prev_stats_mode = info->mount_opts.stats_mode;
+	ret = binderfs_parse_mount_opts(data, &info->mount_opts);
+	if (ret)
+		return ret;
+
+	if (prev_stats_mode != info->mount_opts.stats_mode) {
+		pr_err("Binderfs stats mode cannot be changed during a remount\n");
+		info->mount_opts.stats_mode = prev_stats_mode;
+		return -EINVAL;
+	}
+
+	return 0;
 }
 
 static int binderfs_show_mount_opts(struct seq_file *seq, struct dentry *root)
@@ -333,6 +372,8 @@ static int binderfs_show_mount_opts(struct seq_file *seq, struct dentry *root)
 	info = root->d_sb->s_fs_info;
 	if (info->mount_opts.max <= BINDERFS_MAX_MINOR)
 		seq_printf(seq, ",max=%d", info->mount_opts.max);
+	if (info->mount_opts.stats_mode == STATS_GLOBAL)
+		seq_printf(seq, ",stats=global");
 
 	return 0;
 }
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#2 lore raw

PATCH v3 2/4 binder: Add stats, state and transactions files

In reply to Hridya Valsaraju

The following binder stat files currently live in debugfs.

/sys/kernel/debug/binder/state
/sys/kernel/debug/binder/stats
/sys/kernel/debug/binder/transactions

This patch makes these files available in a binderfs instance mounted with the mount option 'stats=global'. For example, if a binderfs instance is mounted at path /dev/binderfs, the above files will be available at the following locations:

/dev/binderfs/binder_logs/state
/dev/binderfs/binder_logs/stats
/dev/binderfs/binder_logs/transactions

This provides a way to access them even when debugfs is not mounted.

---

Changes in v3:
- Use set_nlink() instead of inc_nlink() in binderfs_create_dir() as per Christian Brauner.
- Replace parent->d_inode usage with d_inode(parent) in binderfs_create_file() for consistency as per Christian Brauner.

Changes in v2:
- Consistently name variables across functions as per Christian Brauner.
- Improve check for binderfs device in binderfs_evict_inode() as per Christian Brauner.

 drivers/android/binder.c          |  15 ++--
 drivers/android/binder_internal.h |   8 ++
 drivers/android/binderfs.c        | 140 +++++++++++++++++++++++++++++-
 3 files changed, 153 insertions(+), 10 deletions(-)
drivers/android/binder.c +6 -9
index ca6b21a53321..de795bd229c4 100644
@@ -6055,7 +6055,7 @@ static void print_binder_proc_stats(struct seq_file *m,
 }
 
 
-static int state_show(struct seq_file *m, void *unused)
+int binder_state_show(struct seq_file *m, void *unused)
 {
 	struct binder_proc *proc;
 	struct binder_node *node;
@@ -6094,7 +6094,7 @@ static int state_show(struct seq_file *m, void *unused)
 	return 0;
 }
 
-static int stats_show(struct seq_file *m, void *unused)
+int binder_stats_show(struct seq_file *m, void *unused)
 {
 	struct binder_proc *proc;
 
@@ -6110,7 +6110,7 @@ static int stats_show(struct seq_file *m, void *unused)
 	return 0;
 }
 
-static int transactions_show(struct seq_file *m, void *unused)
+int binder_transactions_show(struct seq_file *m, void *unused)
 {
 	struct binder_proc *proc;
 
@@ -6198,9 +6198,6 @@ const struct file_operations binder_fops = {
 	.release = binder_release,
 };
 
-DEFINE_SHOW_ATTRIBUTE(state);
-DEFINE_SHOW_ATTRIBUTE(stats);
-DEFINE_SHOW_ATTRIBUTE(transactions);
 DEFINE_SHOW_ATTRIBUTE(transaction_log);
 
 static int __init init_binder_device(const char *name)
@@ -6256,17 +6253,17 @@ static int __init binder_init(void)
 				    0444,
 				    binder_debugfs_dir_entry_root,
 				    NULL,
-				    &state_fops);
+				    &binder_state_fops);
 		debugfs_create_file("stats",
 				    0444,
 				    binder_debugfs_dir_entry_root,
 				    NULL,
-				    &stats_fops);
+				    &binder_stats_fops);
 		debugfs_create_file("transactions",
 				    0444,
 				    binder_debugfs_dir_entry_root,
 				    NULL,
-				    &transactions_fops);
+				    &binder_transactions_fops);
 		debugfs_create_file("transaction_log",
 				    0444,
 				    binder_debugfs_dir_entry_root,
drivers/android/binder_internal.h +8 -0
index fe8c745dc8e0..12ef96f256c6 100644
@@ -57,4 +57,12 @@ static inline int __init init_binderfs(void)
 }
 #endif
 
+int binder_stats_show(struct seq_file *m, void *unused);
+DEFINE_SHOW_ATTRIBUTE(binder_stats);
+
+int binder_state_show(struct seq_file *m, void *unused);
+DEFINE_SHOW_ATTRIBUTE(binder_state);
+
+int binder_transactions_show(struct seq_file *m, void *unused);
+DEFINE_SHOW_ATTRIBUTE(binder_transactions);
 #endif /* _LINUX_BINDER_INTERNAL_H */
drivers/android/binderfs.c +139 -1

158 lines not on this page · raw message

Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#3 lore raw

PATCH v3 3/4 binder: Make transaction_log available in binderfs

In reply to Hridya Valsaraju

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.

---

Changes in v2:
-Consistent variable naming accross functions as per Christian Brauner.

 drivers/android/binder.c          | 34 +++++--------------------------
 drivers/android/binder_internal.h | 30 +++++++++++++++++++++++++++
 drivers/android/binderfs.c        | 18 ++++++++++++++++
 3 files changed, 53 insertions(+), 29 deletions(-)
drivers/android/binder.c +5 -29
index de795bd229c4..bed217310197 100644
@@ -197,30 +197,8 @@ static inline void binder_stats_created(enum binder_stat_types type)
 	atomic_inc(&binder_stats.obj_created[type]);
 }
 
-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];
-};
-static struct binder_transaction_log binder_transaction_log;
-static struct binder_transaction_log binder_transaction_log_failed;
+struct binder_transaction_log binder_transaction_log;
+struct binder_transaction_log binder_transaction_log_failed;
 
 static struct binder_transaction_log_entry *binder_transaction_log_add(
 	struct binder_transaction_log *log)
@@ -6166,7 +6144,7 @@ static void print_binder_transaction_log_entry(struct seq_file *m,
 			"\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;
 	unsigned int log_cur = atomic_read(&log->cur);
@@ -6198,8 +6176,6 @@ const struct file_operations binder_fops = {
 	.release = binder_release,
 };
 
-DEFINE_SHOW_ATTRIBUTE(transaction_log);
-
 static int __init init_binder_device(const char *name)
 {
 	int ret;
@@ -6268,12 +6244,12 @@ static int __init binder_init(void)
 				    0444,
 				    binder_debugfs_dir_entry_root,
 				    &binder_transaction_log,
-				    &transaction_log_fops);
+				    &binder_transaction_log_fops);
 		debugfs_create_file("failed_transaction_log",
 				    0444,
 				    binder_debugfs_dir_entry_root,
 				    &binder_transaction_log_failed,
-				    &transaction_log_fops);
+				    &binder_transaction_log_fops);
 	}
 
 	if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) &&
drivers/android/binder_internal.h +30 -0
index 12ef96f256c6..b9be42d9464c 100644
@@ -65,4 +65,34 @@ DEFINE_SHOW_ATTRIBUTE(binder_state);
 
 int binder_transactions_show(struct seq_file *m, void *unused);
 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 */
drivers/android/binderfs.c +18 -0
index 01c1db463053..9bb54fd3a48a 100644
@@ -630,6 +630,24 @@ static int init_binder_logs(struct super_block *sb)
 
 	dentry = binderfs_create_file(binder_logs_root_dir, "transactions",
 				      &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))
 		ret = PTR_ERR(dentry);
 
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#4 lore raw

PATCH v3 4/4 binder: Add binder_proc logging to binderfs

In reply to Hridya Valsaraju

Currently /sys/kernel/debug/binder/proc contains the debug data for every binder_proc instance. This patch makes this information also available in a binderfs instance mounted with a mount option "stats=global" in addition to debugfs. The patch does not affect the presence of the file in debugfs.

If a binderfs instance is mounted at path /dev/binderfs, this file would be present at /dev/binderfs/binder_logs/proc. This change provides an alternate way to access this file when debugfs is not mounted.

---

Changes in v2:
- Consistent variable naming across functions as per Christian Brauner.
- As suggested by Todd Kjos, log a failure to create a process-specific binderfs log file if the error code is not EEXIST since an error code of EEXIST is expected if
multiple contexts of the same process try to create the file during binder_open().

 drivers/android/binder.c          | 46 ++++++++++++++++++++-
 drivers/android/binder_internal.h | 46 +++++++++++++++++++++
 drivers/android/binderfs.c        | 68 ++++++++++++++-----------------
 3 files changed, 121 insertions(+), 39 deletions(-)
drivers/android/binder.c +44 -2
index bed217310197..ee610ea48309 100644
@@ -481,6 +481,7 @@ struct binder_priority {
  * @inner_lock:           can nest under outer_lock and/or node lock
  * @outer_lock:           no nesting under innor or node lock
  *                        Lock order: 1) outer, 2) node, 3) inner
+ * @binderfs_entry:       process-specific binderfs log file
  *
  * Bookkeeping structure for binder processes
  */
@@ -510,6 +511,7 @@ struct binder_proc {
 	struct binder_context *context;
 	spinlock_t inner_lock;
 	spinlock_t outer_lock;
+	struct dentry *binderfs_entry;
 };
 
 enum {
@@ -5347,6 +5349,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
 {
 	struct binder_proc *proc;
 	struct binder_device *binder_dev;
+	struct binderfs_info *info;
+	struct dentry *binder_binderfs_dir_entry_proc = NULL;
 
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE, "%s: %d:%d\n", __func__,
 		     current->group_leader->pid, current->pid);
@@ -5368,11 +5372,14 @@ static int binder_open(struct inode *nodp, struct file *filp)
 	}
 
 	/* binderfs stashes devices in i_private */
-	if (is_binderfs_device(nodp))
+	if (is_binderfs_device(nodp)) {
 		binder_dev = nodp->i_private;
-	else
+		info = nodp->i_sb->s_fs_info;
+		binder_binderfs_dir_entry_proc = info->proc_log_dir;
+	} else {
 		binder_dev = container_of(filp->private_data,
 					  struct binder_device, miscdev);
+	}
 	proc->context = &binder_dev->context;
 	binder_alloc_init(&proc->alloc);
 
@@ -5403,6 +5410,35 @@ static int binder_open(struct inode *nodp, struct file *filp)
 			&proc_fops);
 	}
 
+	if (binder_binderfs_dir_entry_proc) {
+		char strbuf[11];
+		struct dentry *binderfs_entry;
+
+		snprintf(strbuf, sizeof(strbuf), "%u", proc->pid);
+		/*
+		 * Similar to debugfs, the process specific log file is shared
+		 * between contexts. If the file has already been created for a
+		 * process, the following binderfs_create_file() call will
+		 * fail with error code EEXIST if another context of the same
+		 * process invoked binder_open(). This is ok since same as
+		 * debugfs, the log file will contain information on all
+		 * contexts of a given PID.
+		 */
+		binderfs_entry = binderfs_create_file(binder_binderfs_dir_entry_proc,
+			strbuf, &proc_fops, (void *)(unsigned long)proc->pid);
+		if (!IS_ERR(binderfs_entry)) {
+			proc->binderfs_entry = binderfs_entry;
+		} else {
+			int error;
+
+			error = PTR_ERR(binderfs_entry);
+			if (error != -EEXIST) {
+				pr_warn("Unable to create file %s in binderfs (error %d)\n",
+					strbuf, error);
+			}
+		}
+	}
+
 	return 0;
 }
 
@@ -5442,6 +5478,12 @@ static int binder_release(struct inode *nodp, struct file *filp)
 	struct binder_proc *proc = filp->private_data;
 
 	debugfs_remove(proc->debugfs_entry);
+
+	if (proc->binderfs_entry) {
+		binderfs_remove_file(proc->binderfs_entry);
+		proc->binderfs_entry = NULL;
+	}
+
 	binder_defer_work(proc, BINDER_DEFERRED_RELEASE);
 
 	return 0;
drivers/android/binder_internal.h +46 -0

63 lines not on this page · raw message

drivers/android/binderfs.c +31 -37

99 lines not on this page · raw message

Signature · 1 line
2.23.0.187.g17f5b7556c-goog
Acked-by on the v3 series
#5 lore raw
In reply to Hridya Valsaraju
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Btw, I think your counting is off-by-one. :) We usually count the initial send of a series as 0 and the first rework of that series as v1. I think you counted your initial send as v1 and the first rework as v2. :)

Christian

Quoted 15 lines

Hridya Valsaraju (4):
binder: add a mount option to show global stats
binder: Add stats, state and transactions files
binder: Make transaction_log available in binderfs
binder: Add binder_proc logging to binderfs

 drivers/android/binder.c          |  95 ++++++-----
 drivers/android/binder_internal.h |  84 ++++++++++
 drivers/android/binderfs.c        | 255 ++++++++++++++++++++++++++----
 3 files changed, 362 insertions(+), 72 deletions(-)
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#6 lore raw
Quoted 17 lines · Christian Brauner
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Quoted 6 lines

Btw, I think your counting is off-by-one. :) We usually count the initial send of a series as 0 and the first rework of that series as v1.
I think you counted your initial send as v1 and the first rework as v2.

Which is fine. I have done it both ways. Is this a rule written somewhere?

Quoted 2 lines

:)

If I am not mistaken, this is Hridya's first set of kernel patches. Congrats on landing it upstream and to everyone for reviews! (assuming nothing falls apart on the way to Linus tree).

thanks,

- Joel

[TLDR]
My first kernel patch was 10 years ago to a WiFi driver when I was an intern at University. I was thrilled to have fixed a bug in network bridging code in the 802.11s stack. This is always a special moment so congrats again! ;-)

Quoted 18 lines

Christian

Quoted 10 lines

Hridya Valsaraju (4):
binder: add a mount option to show global stats
binder: Add stats, state and transactions files
binder: Make transaction_log available in binderfs
binder: Add binder_proc logging to binderfs

 drivers/android/binder.c          |  95 ++++++-----
 drivers/android/binder_internal.h |  84 ++++++++++
 drivers/android/binderfs.c        | 255

++++++++++++++++++++++++++----

Quoted 5 lines
 3 files changed, 362 insertions(+), 72 deletions(-)

--
2.23.0.187.g17f5b7556c-goog

#7 lore raw
Quoted 19 lines · Joel Fernandes
Quoted 17 lines · Christian Brauner
Quoted 15 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Quoted 8 lines
Quoted 6 lines

Btw, I think your counting is off-by-one. :) We usually count the initial send of a series as 0 and the first rework of that series as v1.
I think you counted your initial send as v1 and the first rework as v2.

Which is fine. I have done it both ways. Is this a rule written somewhere?

No where, I can count both ways, it's not a big deal :)

greg k-h

#8 lore raw
Quoted 22 lines · Greg Kroah-Hartman
Quoted 21 lines · Joel Fernandes
Quoted 19 lines · Christian Brauner
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Btw, I think your counting is off-by-one. :) We usually count the initial send of a series as 0 and the first rework of that series as v1.
I think you counted your initial send as v1 and the first rework as v2.

Which is fine. I have done it both ways. Is this a rule written somewhere?

No where, I can count both ways, it's not a big deal :)

It isn't documented (as many things we still do are) and it's not a big deal. But most people seem to be counting revisions starting from 0 it seems. I went looking for previous version to link to in the patch cover letter and was confused because I was missing a v1. :)

Anyway, I'm happy that Hridya landed this! It was fun helping her the last couple of weeks on- and off-list. Thanks for getting this done! I hope we'll see even more patches in the future. :)

Christian

#9 lore raw
Quoted 33 lines · Christian Brauner
Quoted 22 lines · Greg Kroah-Hartman
Quoted 21 lines · Joel Fernandes
Quoted 19 lines · Christian Brauner
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Btw, I think your counting is off-by-one. :) We usually count the initial send of a series as 0 and the first rework of that series as v1.
I think you counted your initial send as v1 and the first rework as v2.

Which is fine. I have done it both ways. Is this a rule written somewhere?

No where, I can count both ways, it's not a big deal :)

Quoted 8 lines

It isn't documented (as many things we still do are) and it's not a big deal. But most people seem to be counting revisions starting from 0 it seems. I went looking for previous version to link to in the patch cover letter and was confused because I was missing a v1. :)

Anyway, I'm happy that Hridya landed this! It was fun helping her the last couple of weeks on- and off-list. Thanks for getting this done! I hope we'll see even more patches in the future. :)

Thank you so much Christian and Todd for the guidance and thorough reviews on the many patches I sent your way both on and off-list :) I really appreciate it!

Quoted 2 lines

Christian

#10 lore raw
In reply to Joel Fernandes
Quoted 27 lines · Joel Fernandes
Quoted 17 lines · Christian Brauner
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Quoted 6 lines

Btw, I think your counting is off-by-one. :) We usually count the initial send of a series as 0 and the first rework of that series as v1.
I think you counted your initial send as v1 and the first rework as v2.

Quoted 8 lines

Which is fine. I have done it both ways. Is this a rule written somewhere?

Quoted 2 lines

:)

If I am not mistaken, this is Hridya's first set of kernel patches. Congrats on landing it upstream and to everyone for reviews! (assuming nothing falls apart on the way to Linus tree).

I really hope so! Thank you Joel and everyone else for the reviews !

Quoted 33 lines

thanks,

- Joel

[TLDR]
My first kernel patch was 10 years ago to a WiFi driver when I was an intern at University. I was thrilled to have fixed a bug in network bridging code in the 802.11s stack. This is always a special moment so congrats again! ;-)

Quoted 18 lines

Christian

Quoted 10 lines

Hridya Valsaraju (4):
binder: add a mount option to show global stats
binder: Add stats, state and transactions files
binder: Make transaction_log available in binderfs
binder: Add binder_proc logging to binderfs

 drivers/android/binder.c          |  95 ++++++-----
 drivers/android/binder_internal.h |  84 ++++++++++
 drivers/android/binderfs.c        | 255

++++++++++++++++++++++++++----

Quoted 5 lines
 3 files changed, 362 insertions(+), 72 deletions(-)

--
2.23.0.187.g17f5b7556c-goog

#11 lore raw
In reply to Hridya Valsaraju
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

I'm sitting in a talk from Jonathan about kernel documentation and what I realized is that we forgot to update the documentation I wrote for binderfs in Documentation/admin-guide/binderfs.rst to reflect the new stats=global mount option. Would be great if we could add that after rc1 is out. Would you have time to do that, Hridya?

Should just be a new entry under:

Options
-------
max
binderfs instances can be mounted with a limit on the number of binder devices that can be allocated. The ``max=<count>`` mount option serves as a per-instance limit. If ``max=<count>`` is set then only ``<count>`` number of binder devices can be allocated in this binderfs instance.
stats
<description>

Thanks!
Christian

#12 lore raw
Quoted 18 lines · Christian Brauner
Quoted 9 lines · Hridya Valsaraju

Currently, the only way to access binder state and statistics is through debugfs. We need a way to access the same even when debugfs is not mounted. These patches add a mount option to make this information available in binderfs without affecting its presence in debugfs. The following debugfs nodes will be made available in a binderfs instance when mounted with the mount option 'stats=global' or 'stats=local'.

Quoted 6 lines

/sys/kernel/debug/binder/failed_transaction_log /sys/kernel/debug/binder/proc /sys/kernel/debug/binder/state /sys/kernel/debug/binder/stats /sys/kernel/debug/binder/transaction_log /sys/kernel/debug/binder/transactions

Quoted 5 lines

I'm sitting in a talk from Jonathan about kernel documentation and what I realized is that we forgot to update the documentation I wrote for binderfs in Documentation/admin-guide/binderfs.rst to reflect the new stats=global mount option. Would be great if we could add that after rc1 is out. Would you have time to do that, Hridya?

Thanks for catching that Christian, sorry about the miss! I will send out a patch ASAP to add the documentation.

Regards,
Hridya

Quoted 15 lines

Should just be a new entry under:

Options
-------
max
binderfs instances can be mounted with a limit on the number of binder devices that can be allocated. The ``max=<count>`` mount option serves as a per-instance limit. If ``max=<count>`` is set then only ``<count>`` number of binder devices can be allocated in this binderfs instance.
stats
<description>

Thanks!
Christian