linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Vagin <avagin@openvz.org>
To: linux-fsdevel@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	Andrei Vagin <avagin@openvz.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: [PATCH 2/4] proc: replace seq_printf on seq_putc to speed up /proc/pid/smaps
Date: Mon, 29 Jan 2018 00:00:41 -0800	[thread overview]
Message-ID: <20180129080043.14191-2-avagin@openvz.org> (raw)
In-Reply-To: <20180129080043.14191-1-avagin@openvz.org>

seq_putc() works much faster than seq_printf()

$ time python test_smaps.py

== Before patch ==
real    0m3.828s
user    0m0.413s
sys     0m3.408s

== After patch ==
real	0m3.405s
user	0m0.401s
sys	0m3.003s

== Before patch ==
-   75.51%     4.62%  python   [kernel.kallsyms]    [k] show_smap.isra.33
   - 70.88% show_smap.isra.33
      + 24.82% seq_put_decimal_ull_aligned
      + 19.78% __walk_page_range
      + 12.74% seq_printf
      + 11.08% show_map_vma.isra.23
      + 1.68% seq_puts

== After patch ==
-   69.16%     5.70%  python   [kernel.kallsyms]    [k] show_smap.isra.33
   - 63.46% show_smap.isra.33
      + 25.98% seq_put_decimal_ull_aligned
      + 20.90% __walk_page_range
      + 12.60% show_map_vma.isra.23
        1.56% seq_putc
      + 1.55% seq_puts

Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
---
 fs/proc/task_mmu.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index cc0aaf3a7315..d7a429132a1f 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -685,8 +685,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
 		if (!mnemonics[i][0])
 			continue;
 		if (vma->vm_flags & (1UL << i)) {
-			seq_printf(m, "%c%c ",
-				   mnemonics[i][0], mnemonics[i][1]);
+			seq_putc(m, mnemonics[i][0]);
+			seq_putc(m, mnemonics[i][1]);
+			seq_putc(m, ' ');
 		}
 	}
 	seq_putc(m, '\n');
-- 
2.13.6

  reply	other threads:[~2018-01-29  8:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-29  8:00 [PATCH 1/4] proc: add seq_put_decimal_ull_align to speed up /proc/pid/smaps Andrei Vagin
2018-01-29  8:00 ` Andrei Vagin [this message]
2018-01-29  8:00 ` [PATCH 3/4] proc: optimize single-symbol delimiters to spead up seq_put_decimal_ull Andrei Vagin
2018-01-29  8:00 ` [PATCH 4/4] proc: replace seq_printf by seq_put_smth to speed up /proc/pid/status Andrei Vagin
2018-01-29 19:10 ` [PATCH 1/4] proc: add seq_put_decimal_ull_align to speed up /proc/pid/smaps Alexey Dobriyan
2018-01-29 21:09   ` Andrei Vagin
2018-01-31 16:57     ` Alexey Dobriyan
2018-02-09  0:18     ` Andrew Morton
2018-02-12  8:06       ` Andrei Vagin
  -- strict thread matches above, loose matches on Subject: below --
2018-02-12  7:49 [PATCH 1/4 v2] proc: add seq_put_decimal_ull_width " Andrei Vagin
2018-02-12  7:49 ` [PATCH 2/4] proc: replace seq_printf on seq_putc " Andrei Vagin
2018-02-12 14:10   ` Alexey Dobriyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180129080043.14191-2-avagin@openvz.org \
    --to=avagin@openvz.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).