[PATCH 13/13] proc: convert /proc/*/task/*/children to _print_integer()

From: Alexey Dobriyan
Date: Mon Aug 27 2018 - 19:15:54 EST


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@xxxxxxxxx>
---
fs/proc/array.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

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)
--
2.16.4