Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6442207imm; Mon, 27 Aug 2018 16:17:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYTw6OP8XIJZZepF6OmIls0eb4WgHD3P2nh1qLF1Dz551OW/kiDc2sulowWOYF3mhCdc7wO X-Received: by 2002:a63:3642:: with SMTP id d63-v6mr13651709pga.231.1535411867123; Mon, 27 Aug 2018 16:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535411867; cv=none; d=google.com; s=arc-20160816; b=SBHDAJ2lv8F9F7WHKU3z24wOx4m50HBAs96hU+10XXRcfcP3UqV/5sojq4ZqwvvxbG KraOACNQy2GtpTTsGHoyp1iGvMKY63vtuuGXn+ZmVp49zRNcB1ojPoZElPOddLo9cIBR RT4yo7fB3IgG9M6TEJ3ZpqR3lJz/Kp+oKn2aaZ7fymqucjUDRG2WM2Om8wsfl45X0m7w z6QpvBaFvPmvrBMC+rx08LZf0y5ksJfiUTC1UDRM7uDb5c/BYJ4hkbPT6yyLPzi0Deqv sKQCn6IWTRUevDR0TPUSYgCpkrlL567OG8Fbl6/6/b3KLMNKapWRkqunZvDljm0Td2Y9 eAwQ== 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=Z3Op+bKBKI0WHhSz2U8GtUnIk3zUPlfbkdpOF3B/Wm8=; b=d4J12QNC7Kp0OlwYfByCFoRubDFPJBjvQUTpgtXUizLIF2gUmNmYY1riaktBQlvEcx j8VlGCu/D4STwLNMmRz98Ez4OUuiUxVx3mH2dC8CfraV7msDu1f67kCzaIgrGMtq05iV 5xG4LrHcichO2Ramb5rzDHfeGCkXnFyToreukkZebjsExhdSf7J1rrBLPNr82WF2B0HB cWeuZCCffx7FGv7jS8iHyY36cwgQh8uxX5fIUku/zNFlQDxGBHtVitAPpcvSc0pi89we qD7iTRzR58ySM6sYT5NCl99kIE/q2UpZ9guf8Xre745QCCn+vci8Z7zd9EomLvVXQTGp 9Ouw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nZCxAtEp; 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 d2-v6si486625pgv.76.2018.08.27.16.17.32; Mon, 27 Aug 2018 16:17:47 -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=nZCxAtEp; 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 S1727781AbeH1DEy (ORCPT + 99 others); Mon, 27 Aug 2018 23:04:54 -0400 Received: from mail-ed1-f44.google.com ([209.85.208.44]:46232 "EHLO mail-ed1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727128AbeH1DE1 (ORCPT ); Mon, 27 Aug 2018 23:04:27 -0400 Received: by mail-ed1-f44.google.com with SMTP id k14-v6so421392edr.13 for ; Mon, 27 Aug 2018 16:15:41 -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=Z3Op+bKBKI0WHhSz2U8GtUnIk3zUPlfbkdpOF3B/Wm8=; b=nZCxAtEp5lxqcxBaS/feXLjPoPQwSoT1EdBphqHZ55VauR7P1Wa/Q2U3RGBuRsmM7s Niqjrk3qvQ4TfvBd7F3xejiDAIvcFi+WNNdrBMeGkV9mEnocnew7rnWTGffPCDdg1G2N YmAWqO/Tq6urP91KbytChEeTc1mPXT85d0hwPc7daDksCMJS6SX62lihR8o5gO9syp6V MmeBPv2baMCVRO4xyYwwFbseotTp6lqgOjL+9kFhgzRcZGVsZHocjRF/jKUrdee/0W9r WWtctSCQuCQezVB2w1b0RRGau9O/rleQ1pnrl2xvCK68tGr20i7J76xClnGZdZ7CRRwA Y3sw== 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=Z3Op+bKBKI0WHhSz2U8GtUnIk3zUPlfbkdpOF3B/Wm8=; b=KULHnInXxLS2TQocwVoaLkfwebeEasO+Vk5Jv3znnONlz9VRCsxcVdjPNOsVgyv5oG Uf44Lfuf+zlOqqvREI9gE/6Kh+iYtldEIkt6hf3SW3DStFbW73Iu/hT7J5oxkWU207qA tU6Q2nIGI5d8U64FdsBP0SsDhXdAARolvdme8W/xnyDr2na+jNdhUwWNOxWU9mfXm7AF 4POstRRPwNi+BPFD4Unoj+Lu+gaJx4FrY8d99E1EAzF+j79D8n4qkfagE9qKyrJyeKen UW8CI9c5Xg5BUQhdaO7ZZhECSlZ8bqkPYSsi5kYTlgV9CFcVTLSMQ1YQ8ctZEcggu9Ov Qfng== X-Gm-Message-State: APzg51DbjGKE1gC1+BSPbGkq37x8Bg1RvD/TrsPf2vI/hi+W2SQ+7eaE S1qSGnji1H621OxcJykox9ScDWk= X-Received: by 2002:a50:de03:: with SMTP id z3-v6mr19228204edk.245.1535411740910; Mon, 27 Aug 2018 16:15:40 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 16:15:40 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: [PATCH 10/13] proc: convert readdir /proc to _print_integer() Date: Tue, 28 Aug 2018 02:15:00 +0300 Message-Id: <20180827231503.26899-10-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 readdir("/proc") 2^13 times with 2K processes in a pid namespace: 850.3750 us per readdir 786.5625 -7.5% Signed-off-by: Alexey Dobriyan --- fs/proc/base.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 79d2f7d72ad1..33f444721965 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3223,16 +3223,15 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx) for (iter = next_tgid(ns, iter); iter.task; iter.tgid += 1, iter = next_tgid(ns, iter)) { - char name[10 + 1]; - unsigned int len; + char name[10], *p = name + sizeof(name); cond_resched(); if (!has_pid_permissions(ns, iter.task, HIDEPID_INVISIBLE)) continue; - len = snprintf(name, sizeof(name), "%u", iter.tgid); + p = _print_integer_u32(p, iter.tgid); ctx->pos = iter.tgid + TGID_OFFSET; - if (!proc_fill_cache(file, ctx, name, len, + if (!proc_fill_cache(file, ctx, p, name + sizeof(name) - p, proc_pid_instantiate, iter.task, NULL)) { put_task_struct(iter.task); return 0; -- 2.16.4