KAMEZAWA Hiroyuki 1ac101a5d6 procfs: add num_to_str() to speed up /proc/stat
== stat_check.py
num = 0
with open("/proc/stat") as f:
        while num < 1000 :
                data = f.read()
                f.seek(0, 0)
                num = num + 1
==

perf shows

    20.39%  stat_check.py  [kernel.kallsyms]    [k] format_decode
    13.41%  stat_check.py  [kernel.kallsyms]    [k] number
    12.61%  stat_check.py  [kernel.kallsyms]    [k] vsnprintf
    10.85%  stat_check.py  [kernel.kallsyms]    [k] memcpy
     4.85%  stat_check.py  [kernel.kallsyms]    [k] radix_tree_lookup
     4.43%  stat_check.py  [kernel.kallsyms]    [k] seq_printf

This patch removes most of calls to vsnprintf() by adding num_to_str()
and seq_print_decimal_ull(), which prints decimal numbers without rich
functions provided by printf().

On my 8cpu box.
== Before patch ==
[root@bluextal test]# time ./stat_check.py

real    0m0.150s
user    0m0.026s
sys     0m0.121s

== After patch ==
[root@bluextal test]# time ./stat_check.py

real    0m0.055s
user    0m0.022s
sys     0m0.030s

[akpm@linux-foundation.org: remove incorrect comment, use less statck in num_to_str(), move comment from .h to .c, simplify seq_put_decimal_ull()]
[andrea@betterlinux.com: avoid breaking the ABI in /proc/stat]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrea Righi <andrea@betterlinux.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Turner <pjt@google.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-03-23 16:58:42 -07:00
..
2012-03-21 10:32:00 -07:00
2011-11-02 16:07:03 -07:00
2012-03-20 21:29:46 -04:00
2012-03-21 17:55:01 -07:00
2012-02-28 16:02:54 +01:00
2012-01-03 22:54:57 -05:00
2011-10-29 21:20:22 +02:00
2012-03-23 16:58:38 -07:00
2011-12-13 09:26:45 +00:00
2012-03-20 21:29:37 -04:00
2012-03-20 21:29:53 -04:00
2012-02-20 19:46:36 +11:00
2012-01-04 08:56:31 -06:00
2011-10-31 20:19:04 +00:00
2011-11-26 14:59:39 -05:00
2011-12-11 18:25:16 -05:00
2012-01-12 20:13:04 -08:00
2012-01-03 22:54:58 -05:00
2012-03-20 21:29:41 -04:00
2011-12-13 11:58:49 +01:00
2012-02-28 17:10:21 +00:00
2012-03-20 21:48:30 +08:00
2012-01-03 22:54:56 -05:00
2012-01-03 22:55:17 -05:00
2012-01-09 13:52:09 +01:00
2012-03-08 10:50:35 -08:00
2012-03-21 17:54:57 -07:00
2012-03-23 08:53:47 -07:00
2012-03-08 10:50:35 -08:00
2012-01-17 15:40:51 -08:00
2011-12-27 11:26:41 +02:00
2012-02-29 15:35:41 -06:00
2012-03-15 21:41:34 +01:00
2012-03-03 15:04:45 -05:00
2011-11-14 00:47:54 -05:00
2012-03-06 10:32:47 -05:00
2012-03-05 15:26:47 -05:00
2012-03-21 17:54:58 -07:00
2012-03-21 17:55:01 -07:00
2012-01-06 12:10:26 -08:00
2012-03-22 20:16:14 -07:00
2012-03-09 08:26:05 +01:00
2012-01-12 15:23:04 -08:00
2012-03-16 21:49:24 +01:00
2011-12-13 09:26:45 +00:00
2011-11-02 16:07:02 -07:00
2012-03-20 11:16:20 -07:00
2012-03-23 16:58:41 -07:00
2012-03-20 21:29:38 -04:00
2012-01-03 22:55:07 -05:00
2012-01-03 22:54:56 -05:00
2012-03-08 11:38:50 -08:00
2012-01-09 09:33:57 +09:00
2012-03-19 16:53:08 -04:00
2011-12-13 09:26:45 +00:00
2011-10-31 17:30:47 -07:00
2012-01-03 22:54:56 -05:00
2012-02-02 14:55:45 -08:00
2011-11-02 16:07:02 -07:00
2012-03-08 10:50:35 -08:00