Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6441771imm; Mon, 27 Aug 2018 16:17:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZRnYwLk6l5FGFA8/P0aj333ClwzVhTWcgKduUnJm8WV9fCDfSrq1tUKTro39p705K7SZrf X-Received: by 2002:a63:2583:: with SMTP id l125-v6mr13966261pgl.70.1535411825072; Mon, 27 Aug 2018 16:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535411825; cv=none; d=google.com; s=arc-20160816; b=JrID1xhhjHF3QoCPjEM4pYoe9u0hPOafwAOsp19NgJCG7U6e4T8URZpN3BsfwIhdRN ClFC6WFDU3qWPm+lff4K9BfmKZCcrfDjxqyvtmW7g7DQakn/NaDBI/V1WtH44ZRvMdiy ZgfjYZKHMcZwogIyH6gZnFakIA/x/d9OMVLEsII7Q7DauVcqmQ+w4skyWBGtTfvq146g oBTsDdLFsTdMURADwZEghtQsokz9QM+vh8g5Tj0Ciq5rY28vwpb5/69i0rotQHTvyx2s 9fhbhpnJdB7r5gN3TGFxBEqkVtTMWoCcmIFkPI40JeyemkBTiXVLzzhNcPVTFUtenrot 2x0Q== 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=OrMGb4FasZK/tsEjWe7wC72rwi4YHy+ybAa+ZBp/Xl4=; b=gFg5+RzDpnngJkgG87COQLe7YxEBCx0W/qFuHExgON+n6GS1uUPjrqwpewPfeqJCbJ Xc8nWiU+rgZ8S48OsBrW5he+JiZ5GU6UdzEwkZS/VwP3gUx47Ss5SNFIrdP1tzrCQA1S pNt66rQC/IqYdWSZQkEAYiZ/hggkn9Cq84IoYgdXmGSKhnd4OBUWODtgOKjEEVzIeT7S cJXGPay5xZGldR4PV9FFQf8dvKOB3BSn5Q2tEzR/+RR4ObgTTQ391rC+lTbSWfviXYmy R8vp0uak60NP8c+9cqUxp7esOhFieY2Z+Cg+/auWOHchjnHzOoip1HZ+/a104raYBhlE wiog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fWEmy9a4; 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 67-v6si567443pfc.21.2018.08.27.16.16.50; Mon, 27 Aug 2018 16:17:05 -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=fWEmy9a4; 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 S1727652AbeH1DE2 (ORCPT + 99 others); Mon, 27 Aug 2018 23:04:28 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:44905 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727558AbeH1DE0 (ORCPT ); Mon, 27 Aug 2018 23:04:26 -0400 Received: by mail-ed1-f65.google.com with SMTP id s10-v6so427876edb.11 for ; Mon, 27 Aug 2018 16:15:39 -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=OrMGb4FasZK/tsEjWe7wC72rwi4YHy+ybAa+ZBp/Xl4=; b=fWEmy9a4Yqxwrzl7s0theaP8+HHHMQhejjgM5z2mqmehR7qab5kr0T2p/qDM8fTdLp NxW3kpgjRi9hmAieAy6tEMDF29/i5cidDiSNsex33DsWnvPSRSmuuJAhD6CafrdrXzgS qXrfEf0PeXY4T0zrKm/nN6PPiFkWIrO0FD8wbtnj4kINSFK5z4JQBJy+Wg1qfDQaRzln sbkGmHoTSE5hP1d5AkJ9d0f7EOTZZitWRAZ9xoEAUoamtsYFm4ekkMWUATRwwqyjygjO UulO40tWPUq+KP1ZalP58jIWvyN1X2KCYMFimnxjjFOpgY3DLIq/uCnQ51OgqZDDGy+8 BDew== 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=OrMGb4FasZK/tsEjWe7wC72rwi4YHy+ybAa+ZBp/Xl4=; b=qQC6ZdxawRn9wOeL3d4nEt2Or0OcEZ5YCHChPhchr8eSgrPaI8hDVWQFfmZXfocwVC x1o+6czLCECThws6KGn1r3lEWOs+GZd6YuMTVdvuz9WSR3v9Vwb9UvQpDiyhbxcGCVko /pgh7Qn9SfTuHCawDCJT4qSp4SEjDTi3QSawTj6AG0c+tN1FLpGtkx78GMRQWTLEmjlv 5AbDZ3YRf8Eq/zVWqPrsz6hsO+Jwe3c/hBdNBrCLL39vlM3OEvtq0PNJD/LG/i+wmdwq inDYeKkns4F5k/7q/IWVccWi15W51oeG1Josb5MUVFGDmtT2mOwmaEFJfYGnB8VPcBqj HpSg== X-Gm-Message-State: APzg51DvovIgk2yJnE4kRp5TN2HQG9diWi4Yw6sFh9zlsos3U8xVsBBp Hm2UZ6QWlu+y3XvmHNl13c7jhhA= X-Received: by 2002:a50:9297:: with SMTP id k23-v6mr18829121eda.180.1535411739176; Mon, 27 Aug 2018 16:15:39 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 16:15:38 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: [PATCH 08/13] proc: convert /proc/*/fd to _print_integer() Date: Tue, 28 Aug 2018 02:14:58 +0300 Message-Id: <20180827231503.26899-8-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 opendir+readdir("/proc/self/fd")+closedir 2^21 times with 4 descriptors (0, 1, 2, 3 from opendir): 11.802099126 seconds time elapsed ( +- 0.23% ) 10.950810068 seconds time elapsed ( +- 0.23% ) -7.2% Benchmark the same thing with 1000 descriptors: 362.1250 us per iteration 288.4375 us -20% Signed-off-by: Alexey Dobriyan --- fs/proc/fd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/fd.c b/fs/proc/fd.c index e098302b5101..60ad1935eefc 100644 --- a/fs/proc/fd.c +++ b/fs/proc/fd.c @@ -247,8 +247,7 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx, fd++, ctx->pos++) { struct file *f; struct fd_data data; - char name[10 + 1]; - unsigned int len; + char name[10], *p = name + sizeof(name); f = fcheck_files(files, fd); if (!f) @@ -257,9 +256,10 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx, rcu_read_unlock(); data.fd = fd; - len = snprintf(name, sizeof(name), "%u", fd); + p = _print_integer_u32(p, fd); if (!proc_fill_cache(file, ctx, - name, len, instantiate, tsk, + p, name + sizeof(name) - p, + instantiate, tsk, &data)) goto out_fd_loop; cond_resched(); -- 2.16.4