Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6442964imm; Mon, 27 Aug 2018 16:18:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaDNq6iVotDTJCxrw+FqQjCVxXv835QmSXyoQn1vwO2+XBf4dwvBKxtC6HsZJuOa+sLuH4n X-Received: by 2002:a65:5144:: with SMTP id g4-v6mr13665508pgq.21.1535411927265; Mon, 27 Aug 2018 16:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535411927; cv=none; d=google.com; s=arc-20160816; b=HxzGuZD5pFMzJClXNjakqzENv+ZWBW7H9P+ZQUw4BJ25fS6us/BPO7DPsKeyBKDLqw qv28AFmbt879eUy/ZrLavBl3J2opnxL3RPT9xrRWdQ4FmnRC7opRJXLR4tfZPpCpQ564 1LZ/HypQNJM8FshQj7PYdqD1pDhPFCulkdKlujFNgSdYnv9LfrYhhCWYfb+ryW5HqHvH 2dBD9D8cFGvONvS8W4H8Nk+lE2RAiYxOyQu98k1veZEd1iO1yCYwLMz5sREJl4IFGTwC NVC0aTnmPVWXn7+YvqHKLuRDsCnd/AJymIo3e6+MN+gljR2k2hBBwr40MG8UAsft9pEU xIqg== 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=gNlPfOGxOIZa+4NOTZu7u0ClBakEI0ySfd7crmTmBok=; b=0JslmO0fKWV9xuM5D2vXf5iXqSrcSLBqzyfhaJRxnP0Ll3YKz85G6+TUBsnQs0XcIG hdGKHdq8oe8la3wnqwsxGcMJm6R7FbJTTmV0mV9yjxgPbAy0erk7hOgxK/zcwgYiGaQJ fC1GQA1Bq/ZyngfrmtwQztm0UDDtamIeEwpCtCgWARPyzpMOpbtzIAEz6r2yranaKxy5 peZVy8xMzNiCQ9ybp3dktnDD6DyV0jT40DP4y64zkxHg83vVrLHgRaX0Q5RxRcmcutFX tVq66fCsUGVM13D4dRDvGZO91eXzjr2JxtbL+Gl+qR/MKUGg3IvTOTAasI1VyDZ3PNfO hJpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Rg7O27oH; 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 z127-v6si527686pgb.455.2018.08.27.16.18.31; Mon, 27 Aug 2018 16:18: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=Rg7O27oH; 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 S1727794AbeH1DFM (ORCPT + 99 others); Mon, 27 Aug 2018 23:05:12 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:43271 "EHLO mail-ed1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbeH1DEZ (ORCPT ); Mon, 27 Aug 2018 23:04:25 -0400 Received: by mail-ed1-f48.google.com with SMTP id z27-v6so432765edb.10 for ; Mon, 27 Aug 2018 16:15:38 -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=gNlPfOGxOIZa+4NOTZu7u0ClBakEI0ySfd7crmTmBok=; b=Rg7O27oHAqvTc2QZKHSjlxFLrmKULHaU1aOLu9oSlBPKM7aigUgtSMIq6Wyl/J7WGX +AB2VHAp6ttxOqrhL6rzmhmJHW7Ti505h6UWsuA+vF9icyjW1IZ/xcVJmRyl935vmtk/ hVGiCPG4gbI3y2zEfgRJYKuKS8jIbUWfWngwvli2TJvk7d1D4a2MNVzkqzpea8QgoFkU OQpWmOWdKYAw8QpUZTXW5ukhQo5aOVXAPPc07q7OuN8RRHwh1UPcvqL1g1zaEEl7N0yE bpxaQjM0uHIQEeWHJ7M9eSCJMHnsjd5MrryxWZZ8f/KHm/00UZqquK5EIkxxmMJh6XIH kk9A== 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=gNlPfOGxOIZa+4NOTZu7u0ClBakEI0ySfd7crmTmBok=; b=UbK41udXPJhbx6FYdn4CjfYCvQEfwrs6yK7t+zK8w97wydFNAv4CJNZblMU3oY8Sf5 zUpO1Tjoxgs4MM/28VIF9JruqJO+5oYJq3KzifYPiiKfBvGsxbhDHnMoyh/kU4I4i8+O RFW75cOtD1ne1Ia/AnCokEo8NDPWTskMy86YrnWsC2XBTay8+F4AiH4ev25Tszihy5QC YEmN0r4a31ogI9pYPYZrPESIDf+DtSw7/ZCRpOHqIqDAyPAbovRvTfPMSeul2OiXh7WO CT3Ek/77HzTNCcuQWaEl4meLaL6ZrrzoaDHap0NKDlut3j564YpK0IqnySyE06qGj5gV A/cA== X-Gm-Message-State: APzg51Ckxpno3/RMMb4EibSst7CCAI32URDNsCA5AzcxOYTDzks6mLA/ nGqbMBZDV+1yHgnqF586HA== X-Received: by 2002:a50:c44a:: with SMTP id w10-v6mr4992624edf.274.1535411738158; Mon, 27 Aug 2018 16:15:38 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 16:15:37 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan Subject: [PATCH 07/13] proc: convert /proc/thread-self to _print_integer() Date: Tue, 28 Aug 2018 02:14:57 +0300 Message-Id: <20180827231503.26899-7-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/thread-self") 2^23 times: 9.447948508 seconds time elapsed ( +- 0.06% ) 7.846435274 seconds time elapsed ( +- 0.07% ) -17% --- fs/proc/thread_self.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c index b905010ca9eb..03dd644d8ada 100644 --- a/fs/proc/thread_self.c +++ b/fs/proc/thread_self.c @@ -15,6 +15,7 @@ static const char *proc_thread_self_get_link(struct dentry *dentry, struct pid_namespace *ns = proc_pid_ns(inode); pid_t tgid = task_tgid_nr_ns(current, ns); pid_t pid = task_pid_nr_ns(current, ns); + char buf[10 + 6 + 10], *p = buf + sizeof(buf); char *name; if (!pid) @@ -22,7 +23,13 @@ static const char *proc_thread_self_get_link(struct dentry *dentry, name = kmalloc(10 + 6 + 10 + 1, dentry ? GFP_KERNEL : GFP_ATOMIC); if (unlikely(!name)) return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); - sprintf(name, "%u/task/%u", tgid, pid); + + p = _print_integer_u32(p, pid); + p = memcpy(p - 6, "/task/", 6); + 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