lkml.org 
[lkml]   [2018]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 10/13] proc: convert readdir /proc to _print_integer()
Date
Benchmark readdir("/proc") 2^13 times with 2K processes in a pid
namespace:

850.3750 us per readdir
786.5625

-7.5%

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

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 79d2f7d72ad1..33f444721965 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -3223,16 +3223,15 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
for (iter = next_tgid(ns, iter);
iter.task;
iter.tgid += 1, iter = next_tgid(ns, iter)) {
- char name[10 + 1];
- unsigned int len;
+ char name[10], *p = name + sizeof(name);

cond_resched();
if (!has_pid_permissions(ns, iter.task, HIDEPID_INVISIBLE))
continue;

- len = snprintf(name, sizeof(name), "%u", iter.tgid);
+ p = _print_integer_u32(p, iter.tgid);
ctx->pos = iter.tgid + TGID_OFFSET;
- if (!proc_fill_cache(file, ctx, name, len,
+ if (!proc_fill_cache(file, ctx, p, name + sizeof(name) - p,
proc_pid_instantiate, iter.task, NULL)) {
put_task_struct(iter.task);
return 0;
--
2.16.4
\
 
 \ /
  Last update: 2018-08-28 01:16    [W:0.085 / U:0.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site