From patchwork Mon Feb 12 07:49:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Vagin X-Patchwork-Id: 10211935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95BB060153 for ; Mon, 12 Feb 2018 07:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88899288F1 for ; Mon, 12 Feb 2018 07:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D62428C03; Mon, 12 Feb 2018 07:49:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F16288F1 for ; Mon, 12 Feb 2018 07:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbeBLHtj (ORCPT ); Mon, 12 Feb 2018 02:49:39 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43896 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbeBLHth (ORCPT ); Mon, 12 Feb 2018 02:49:37 -0500 Received: by mail-pg0-f66.google.com with SMTP id f6so7007029pgs.10 for ; Sun, 11 Feb 2018 23:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=oMkds0y0qRnq9l1k6TsEY5Ri/3O0jso3iOM8oAHZAeI=; b=GszzNgQVtJIsX9VjuN3k9Qt1AfW+9cRnsvPuGck4Mm4vEO9r7sRHyHUTW2T60HYX1w FZz1/g8VNB/HFwOEAS0hB3WiAKnq65S3HFDk2UrQ7LCN91PB4dQw0gRUE24XLPCfC6yV xTagSTZc0yusqPd2Nu5ijsKMwx3G8epIA/o+oPnmjrGjnczqr4LnKEIqUPAcOjYgBOdZ mfuXgraFQm6uTqdIOK2Ss6C/JysMql5xC77tMeBfgVhrstaTjdehWhtVPvpUih2GQlBP XueXy2kbfN/DCk0TolAoiC8kJ2C5PruSXFOwxRlXUjjTvvJn8vKZvDem/OMrTtMDOR8F di7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=oMkds0y0qRnq9l1k6TsEY5Ri/3O0jso3iOM8oAHZAeI=; b=GZD/jK2JjewaiRTxPDRS7alqLk2K5DlCOlMz6uCSxdP1Hem4941J/j/IfP7nLnSAyq ELiOH2drQcFtQo46QGji7t+EWsRS709gpbXHB7NYvVxtbDhMmjh7RhoRPpKGfyRMV05s z8N4AclWOVMWtj1ZXQSw2hImt7BYKrrTs94swBNEGTKyqGH1mF7Ec10dj1n9LjoK16DZ PjIckRepGxybbwZ7DWSc7CAi/jx/vKwDosobIpPREVtRlbp2Is/gRhSiWtsLRUygeE0z QYc+lPMvjlZb918xz0Fs/MxWVQ6uh55jx545UohJRH9YILVr3h1MIVaiRg7Cn6u9t+JE lnGA== X-Gm-Message-State: APf1xPCQ0MFLTY4g0TjrFdJdbpobSaZJ3u1hJDOolot+miSUxTUD/t8z S63r4ozITqHyFWrL4FJz1C6cHZ2v X-Google-Smtp-Source: AH8x227nU/7nbJwYC8so9gAkiGbesAglntF+LUgvw/fxf4AhoSM/Qs/qejnTJErawixBV99tPV2Zfg== X-Received: by 10.99.95.71 with SMTP id t68mr6723358pgb.321.1518421776246; Sun, 11 Feb 2018 23:49:36 -0800 (PST) Received: from localhost.localdomain (c-73-140-212-29.hsd1.wa.comcast.net. [73.140.212.29]) by smtp.gmail.com with ESMTPSA id x71sm26623102pfe.182.2018.02.11.23.49.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 23:49:35 -0800 (PST) From: Andrei Vagin To: linux-fsdevel@vger.kernel.org, Andrew Morton Cc: Alexey Dobriyan , Andrei Vagin , KAMEZAWA Hiroyuki Subject: [PATCH 2/4] proc: replace seq_printf on seq_putc to speed up /proc/pid/smaps Date: Sun, 11 Feb 2018 23:49:29 -0800 Message-Id: <20180212074931.7227-2-avagin@openvz.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180212074931.7227-1-avagin@openvz.org> References: <20180212074931.7227-1-avagin@openvz.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: KAMEZAWA Hiroyuki Signed-off-by: Andrei Vagin Reviewed-by: Alexey Dobriyan --- 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 3026feda0432..65ae54659833 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -688,8 +688,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');