[13/13] proc: convert /proc/*/task/*/children to _print_integer()
diff mbox series

Message ID 20180827231503.26899-13-adobriyan@gmail.com
State New, archived
Headers show
Series
  • [01/13] seq_file: rewrite seq_puts() in terms of seq_write()
Related show

Commit Message

Alexey Dobriyan Aug. 27, 2018, 11:15 p.m. UTC
Benchmark pread /proc/1/task/1/children 2^21 times on the same system:

	6.766400479 s
	4.328648442

	-36%

(need to remeasure on a controlled set of children)

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/proc/array.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/fs/proc/array.c b/fs/proc/array.c
index d0565527166a..045ce2cac1dd 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -710,9 +710,11 @@  get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
 static int children_seq_show(struct seq_file *seq, void *v)
 {
 	struct inode *inode = file_inode(seq->file);
+	char buf[10 + 1], *p = buf + sizeof(buf);
 
-	seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(inode)));
-	return 0;
+	*--p = ' ';
+	p = _print_integer_u32(p, pid_nr_ns(v, proc_pid_ns(inode)));
+	return seq_write(seq, p, buf + sizeof(buf) - p);
 }
 
 static void *children_seq_start(struct seq_file *seq, loff_t *pos)