Received: by 10.223.176.5 with SMTP id f5csp425053wra; Wed, 7 Feb 2018 01:27:45 -0800 (PST) X-Google-Smtp-Source: AH8x226bKfGvzFtJcSAM4ZZnCfMtywi++9iK/NXU6NdYxzcfsD7GEaDQIcFxh3JDvubYZpJIZXVT X-Received: by 2002:a17:902:7e43:: with SMTP id a3-v6mr5495502pln.138.1517995664971; Wed, 07 Feb 2018 01:27:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517995664; cv=none; d=google.com; s=arc-20160816; b=Rbzauv/2Xv1k0CWEtI22uK06I/vZ2WuRtC/nw2q000dFVApcDagzHAqAmuKU1LaVhR aMXzmaYeuxhae3g76xZHQS3scqz3jKSAahETj8kZ3yT5F321yr4ZDJV1zXIc50OW2nS1 8Tnt7nnIwiTU+aT8yg6c+MmMQCLCXfg515mam4aYazBWfDxTAfIUcd77DJ/eF9fX0Wv/ U4mfNCAUAEzNaMGB7Dq3HFakbmLQCfKozlI1CakAwThLvR0dZcoxmSZ0vZsld90+LNfj HIBb/H9qr/7KQlwWN8aNSnZsxDFaQA9QtQXFYW4haTnsUGSwfPSvwHfyyzmcKgzRkhvw AG9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hS3h+wg6q/9i7fW6575HTHRKFo4YuFXsugeshlJRdOU=; b=C8qgc6W+m0RG93dniYyp2VSdafQbQw87zjLaYhYPrrhQInho4D1mQUD8PEaeD0m+K6 8NFObiX5WyGPS2rUGEeEtmXrtQpZ6+UbtuLg+KBDEDnNwnBfvkyvvP/0RXknNU+xp0pG QuRT79CMzFG93zWiOI2A0DEOVE1R7LnhNl3MXb1NDK7Hp/ZRGZYAjMUDEUg3h41ydc8f /ckmFItER8t+SYFeFIkiq5kzrzMaijCJyBcBp2RWO6v8BSwMdTYWx/cpy1A6jq9np6KY ojsZyjA9U3qrKH5SAumSnX+jqBCaDcY2e96FGJ19qS7dd84pJ/VtudrxOEDq0IN5J+mx Jc+g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v35-v6si811101plg.724.2018.02.07.01.27.31; Wed, 07 Feb 2018 01:27:44 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753496AbeBGJ0x (ORCPT + 99 others); Wed, 7 Feb 2018 04:26:53 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753066AbeBGJ0v (ORCPT ); Wed, 7 Feb 2018 04:26:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4457140FB62E; Wed, 7 Feb 2018 09:26:51 +0000 (UTC) Received: from mguzik.localdomain (ovpn-204-36.brq.redhat.com [10.40.204.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40749DEED8; Wed, 7 Feb 2018 09:26:50 +0000 (UTC) From: Mateusz Guzik To: Andrew Morton Cc: Konstantin Khlebnikov , Jerome Marchand , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] proc: get rid of task lock/unlock pair to read umask for the "status" file Date: Wed, 7 Feb 2018 10:26:48 +0100 Message-Id: <1517995608-23683-1-git-send-email-mguzik@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Feb 2018 09:26:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 07 Feb 2018 09:26:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mguzik@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org get_task_umask locks/unlocks the task on its own. The only caller does the same thing immediately after. Utilize the fact the task has to be locked anyway and just do it once. Since there are no other users and the code is short, fold it in. Signed-off-by: Mateusz Guzik --- fs/proc/array.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index d67a72d..5f0ec1f 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -141,25 +141,12 @@ static inline const char *get_task_state(struct task_struct *tsk) return task_state_array[task_state_index(tsk)]; } -static inline int get_task_umask(struct task_struct *tsk) -{ - struct fs_struct *fs; - int umask = -ENOENT; - - task_lock(tsk); - fs = tsk->fs; - if (fs) - umask = fs->umask; - task_unlock(tsk); - return umask; -} - static inline void task_state(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *p) { struct user_namespace *user_ns = seq_user_ns(m); struct group_info *group_info; - int g, umask; + int g, umask = -1; struct task_struct *tracer; const struct cred *cred; pid_t ppid, tpid = 0, tgid, ngid; @@ -177,16 +164,16 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns, ngid = task_numa_group_id(p); cred = get_task_cred(p); - umask = get_task_umask(p); - if (umask >= 0) - seq_printf(m, "Umask:\t%#04o\n", umask); - task_lock(p); + if (p->fs) + umask = p->fs->umask; if (p->files) max_fds = files_fdtable(p->files)->max_fds; task_unlock(p); rcu_read_unlock(); + if (umask >= 0) + seq_printf(m, "Umask:\t%#04o\n", umask); seq_printf(m, "State:\t%s", get_task_state(p)); seq_put_decimal_ull(m, "\nTgid:\t", tgid); -- 1.8.3.1