Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6441739imm; Mon, 27 Aug 2018 16:17:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYdox1d9nnBuQBA6A+OyhlJ0TjxI6HoDC3Xf/wy6ozBHdta7xDQe/HHGASIJIPHXRLXIn7J X-Received: by 2002:a17:902:1101:: with SMTP id d1-v6mr15203909pla.131.1535411822782; Mon, 27 Aug 2018 16:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535411822; cv=none; d=google.com; s=arc-20160816; b=t2Vi6AOzGC63RYB8z3tn9qjvQkxkzW33z4+eKUUVEVJdKruIUOiD18oRlM4vJr87PV vbJ6B3/YwI46skzThXYXuKYweIVt9d/euqlWUK0HG7wSZONSP2eiddk7Iox2+mDvJWpG Q3kh0RYdzjkovzGyRh5jWK5GMlGwq/woRY3Ftj4CbgkVVbFO91yLaB0dlziWzzhb2f2c MS/N1tfrAXbbTjPWP06bQaemM3ockd6FSjiPgVKZWVQMM4xERNTs+v/Ic6i8MzfBVY6w lNnrWHB8Q5Y2eqQWUbfT3lX4NbQjl7tGoZrzmSbSmBSn/Uq863vppDJ6BWHpS4zBQFrt 3VlQ== 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=Zr+Bw9zcrgyZNkjKwCaNpun0BBxJG2M1r0qHuQ1HOUc=; b=RjkOW1tOr9PEr/xcVhRY0GmJ3ScX3aWjGsrncICaOSrEF/KHYr0JK/AkPfNcGCU8qu GqymI42drs6E+mki4UgUxFoNEcshUf8h0q+TgtpEpR5JCzFaCrnwqMPQ+alxVwm9U/bt CVohREEAVh849RmCkPFPsL4wfOwJ2Au9fnDDQnkPcBE4QBfznM6K+tlloUBt8JsTO5JV MCShHn/c1y3GIIjp0DygJm8BeI94rXgNrYWgmycmbphQQy/kqKXH2RMTPRCqxs1wmg72 45A2kxDlXMAXu7R8bLojysab+gJCt9Osdcu9dO6d5YdK3bnHdSv3U4LwrJWNxDBL8UGj UN0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DGm5jD9c; 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 z3-v6si502901plb.418.2018.08.27.16.16.48; Mon, 27 Aug 2018 16:17:02 -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=DGm5jD9c; 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 S1727597AbeH1DEZ (ORCPT + 99 others); Mon, 27 Aug 2018 23:04:25 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:46711 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727459AbeH1DEY (ORCPT ); Mon, 27 Aug 2018 23:04:24 -0400 Received: by mail-ed1-f68.google.com with SMTP id k14-v6so421315edr.13 for ; Mon, 27 Aug 2018 16:15:37 -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=Zr+Bw9zcrgyZNkjKwCaNpun0BBxJG2M1r0qHuQ1HOUc=; b=DGm5jD9cVxoA9dGhv59FVeI+sI4Qr2hV+fUNNksjFlgVfmkbgntNAmt5k/MDge//gM 0Q5ziVyjghzMkHtMRgFsjyU9hX/U3V5IieKXxVHw6+f9ygBcXsZqeNXJG5hsFYojIYfH ltofCN3fdEeBcDATk2X/hpyImXAeANbwKvijzuX8b45/lDuVurICO8i2VRaIxjdiiy6C evWRpI3On7+6Izvf+AhVbNcEx8bl2hP+CdyQGBCsuw4VWa8FY/xP0FSpX2XftA10EB54 0Qj80VedEB+iUZAcBwy17F613rE84YJ5k5Ybtkm2l8BfTj4KA9Fmpk0UtmqlxP3SdJby UxXA== 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=Zr+Bw9zcrgyZNkjKwCaNpun0BBxJG2M1r0qHuQ1HOUc=; b=JjkJ/+B0fnwM41WGRSJa7rHZeULo+F7dVSfiQOnuEVhm2MmWOZ/JSJyk6j0knlu0Pt KhZzLuSy9+41vp3fBQyURWjw9bxbLW/a67yg+TBKpXy55jqtRrTBOM/Au4SWkFjY3dHu Fnknd+NTgobV/tkP1y6yJEg9PCgRBSKaoEwpkbOI3nZvSo03xoQaDfPupnLXe+/Viw9C K6/mzHinUWar8jehhB+I6UL516oSTz0QMpuxAEt4gf3Hmxbovm784VX7AyOQthcvLlOP rHKOMUYwI53zf56kceKnb7cCAQs/9BVPYXZCSwzW9gl9nRFJn6MdiXJyfi7LuJXOoY99 NPLQ== X-Gm-Message-State: APzg51Aj94b/DfbywSC1BsnckRpZePo2CSN6tryNy8KlAUTNnNSJBCf7 wSBwcYJHTw2ebMKuyJj3FsgDjWM= X-Received: by 2002:aa7:d391:: with SMTP id x17-v6mr19213780edq.144.1535411737276; Mon, 27 Aug 2018 16:15:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 16:15:36 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: [PATCH 06/13] proc: convert /proc/self to _print_integer() Date: Tue, 28 Aug 2018 02:14:56 +0300 Message-Id: <20180827231503.26899-6-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 readlink("/proc/self") 2^23 times: 8.205992458 seconds time elapsed ( +- 0.15% ) 7.535168869 seconds time elapsed ( +- 0.09% ) -8.2% Signed-off-by: Alexey Dobriyan --- fs/proc/self.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/proc/self.c b/fs/proc/self.c index 127265e5c55f..b2279412237b 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c @@ -14,6 +14,7 @@ static const char *proc_self_get_link(struct dentry *dentry, { struct pid_namespace *ns = proc_pid_ns(inode); pid_t tgid = task_tgid_nr_ns(current, ns); + char buf[10], *p = buf + sizeof(buf); char *name; if (!tgid) @@ -22,7 +23,11 @@ static const char *proc_self_get_link(struct dentry *dentry, name = kmalloc(10 + 1, dentry ? GFP_KERNEL : GFP_ATOMIC); if (unlikely(!name)) return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); - sprintf(name, "%u", tgid); + + p = _print_integer_u32(p, tgid); + memcpy(name, p, buf + sizeof(buf) - p); + name[buf + sizeof(buf) - p] = '\0'; + set_delayed_call(done, kfree_link, name); return name; } -- 2.16.4