Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6442062imm; Mon, 27 Aug 2018 16:17:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY9pkaL8FZnI59dSm7ElwnNIKmIcuVlrQKfYvKOXG2TTJYMTmjlZTYQtoaS7jsFl3eF6hlZ X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr16282522pfh.141.1535411852083; Mon, 27 Aug 2018 16:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535411852; cv=none; d=google.com; s=arc-20160816; b=oA+WRzyvse/zPnF8dGMpc1VFMOGLwf2YLs7vW52BpdX31PUU/NrIEWS4ubOo/OUqyy 7Lysy+msy1XWPLoI4Q//QSjuTlsMi9XVMdnSx87FhG5TVWeB3LHeB+ZExAFpweMvdeqF aXz/2OUsUs/blisidWz/nkb+GKoafJipXYGNct85iTGTOthpVdEkqQfZRWycS4kJIQOt KpZPmOoWC2p1/W+wyep0FcpgDww3rS791XPGhIu4mA3yvZ0HpxFJ2yexYeoQVW9hYvgm MQRwojSm8Si9fA9uXnSpImeAkCOajjVVJgUpAPgKEYdfJShgAdRM9ja3ThF+yIpqwaYJ LSKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=6nR0pRfLmUj2PZ5flmuLWsdHEztq2/Q+Stf4rFsnIdw=; b=v2H8IRlC8WyjVk/4YLgeMujujd/VC3RQYgxZU6PENOTZoP1/oBD89zVEUixxsNRra2 slBSjTa5VASD6K46aovwO9fwk+XnX37FJAYScajVzg2G/BcYWw+wPC/Cuy2+vMv4CLL8 RH1zZsa3GwwDUSFVeqHZhKhQiqO4Mwq5TeMv61eumlPtMny9N7QKjnmM/kPLBDjhtEXP Crprs0cG/orKM6HDXeGFXNz8mfmW/Sis+TL6duIettIglqHxG+ZEiGeMEJ6BdCwvzD2v ezg684pbafF1T0R4hxO8PgM961RmCL47pGYzu5Uc35g670gWAchGZ8uiQXSdQg6qyYft 2XLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H2y5rWX1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q145-v6si533225pfq.315.2018.08.27.16.17.16; Mon, 27 Aug 2018 16:17:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H2y5rWX1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727742AbeH1DEb (ORCPT + 99 others); Mon, 27 Aug 2018 23:04:31 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:42884 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727558AbeH1DEa (ORCPT ); Mon, 27 Aug 2018 23:04:30 -0400 Received: by mail-ed1-f67.google.com with SMTP id r10-v6so438590edp.9 for ; Mon, 27 Aug 2018 16:15:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6nR0pRfLmUj2PZ5flmuLWsdHEztq2/Q+Stf4rFsnIdw=; b=H2y5rWX1cbcjcAyoLcst6BaSqBAY6jZ/y1GIfHLOt796XhkIcz7knbPGg+5IkCFfj6 8FFpwvS0jnLx90nDBXjPA1fRj3crXfeCAoC+rX3lWH6ys4sEIF9We6zNUYvs1RXhk1c2 tQOYlTjWYrUl0oB3TH4KYJkznxs2uOAEKBlhmWD5bBuzYrkJW58dW8pp7G8afGUjnZgf kJRskOu8zjk70hWtNEOcLHvS0nyQN+lStlyDRUwXDmagfSGbgJMqIPXo4y9dw9WEszr/ ru4W/EkC1aiezvCGXH5Z23kaypHI5arjX/ugLQxvV8x23K7gvIvA5QpWN75r0zJyiERK 7fug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6nR0pRfLmUj2PZ5flmuLWsdHEztq2/Q+Stf4rFsnIdw=; b=U244Xp8uLHVbn9hY2y1Cbu8c1buE7cJiRtDCNBu4SHic877qsEiCHsYPqvxn65M3Jv Uzu82cIlnZBxZfGFObtnuUh0VMyeo+09hoF8+ihWisgvxAFdQgXlE/ptUmTD4DTpZmsh x/3UHJN7TOs44NNKLwwoGVG6MMcxM5U1J/WQm2wpA+EbM2s/mFxdQYhXAqLdts2/s5Yh BMhkr4ktKclYGZsO9ElxubdzAQRV89T+379eCe8SV/734NmRfmb52raXBD5pT90lORaH ZixpQBFNh85HgCBOyEGWZ2XDzY5WsL6EFhaxB3A0mqvUgCygyBp9VmaaDKtYgYbrVuDn GsVA== X-Gm-Message-State: APzg51BV75rQvfxMiGSdXzX/S0HnKwM+wYZUckn52qhfbuoeMqnMuEOz jm030Hwatw+CdR0lAnX+SA== X-Received: by 2002:a50:f0c2:: with SMTP id a2-v6mr19510197edm.90.1535411742705; Mon, 27 Aug 2018 16:15:42 -0700 (PDT) Received: from localhost.localdomain (nat4-minsk-pool-46-53-177-92.telecom.by. [46.53.177.92]) by smtp.gmail.com with ESMTPSA id u3-v6sm173918edo.44.2018.08.27.16.15.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 16:15:42 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: [PATCH 12/13] proc: convert /proc/*/statm to _print_integer() Date: Tue, 28 Aug 2018 02:15:02 +0300 Message-Id: <20180827231503.26899-12-adobriyan@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180827231503.26899-1-adobriyan@gmail.com> References: <20180827231503.26899-1-adobriyan@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Benchmark pread("/proc/self/statm") 2^23 times: 6.135596793 seconds time elapsed ( +- 0.11% ) 5.685442773 seconds time elapsed ( +- 0.11% ) -7.3% Signed-off-by: Alexey Dobriyan --- fs/proc/array.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 5016e03a4dba..d0565527166a 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -627,27 +627,27 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, { unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0; struct mm_struct *mm = get_task_mm(task); + /* "%lu %lu %lu %lu 0 %lu 0\n" */ + char buf[5 * ((sizeof(long) * 5 / 2) + 1) + 2 + 2]; + char *p = buf + sizeof(buf); if (mm) { size = task_statm(mm, &shared, &text, &data, &resident); mmput(mm); } - /* - * For quick read, open code by putting numbers directly - * expected format is - * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n", - * size, resident, shared, text, data); - */ - seq_put_decimal_ull(m, "", size); - seq_put_decimal_ull(m, " ", resident); - seq_put_decimal_ull(m, " ", shared); - seq_put_decimal_ull(m, " ", text); - seq_put_decimal_ull(m, " ", 0); - seq_put_decimal_ull(m, " ", data); - seq_put_decimal_ull(m, " ", 0); - seq_putc(m, '\n'); - return 0; + p = memcpy(p - 3, " 0\n", 3); + p = _print_integer_ul(p, data); + p = memcpy(p - 3, " 0 ", 3); + p = _print_integer_ul(p, text); + *--p = ' '; + p = _print_integer_ul(p, shared); + *--p = ' '; + p = _print_integer_ul(p, resident); + *--p = ' '; + p = _print_integer_ul(p, size); + + return seq_write(m, p, buf + sizeof(buf) - p); } #ifdef CONFIG_PROC_CHILDREN -- 2.16.4