Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3880994pxb; Mon, 4 Oct 2021 11:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbCiOJp4+ojH0THy3AcQy39jnCKS9nflD6spLlccA6GyvRb/gwaCx+cW0ki1i5C9JqaGVB X-Received: by 2002:a17:906:1454:: with SMTP id q20mr19337235ejc.446.1633372867962; Mon, 04 Oct 2021 11:41:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1633372867; cv=pass; d=google.com; s=arc-20160816; b=QklmLQEUATwcP6FH9DC3kGEoaWCpTTbmFs2OHvmAGVtdst7jxn+xUUeufY1lxVRwKz 0PVZN4IMMyHY7IKmNc785QZjBFm9wkW8av6VRLyWkuZJdyAG/iH3F7V3k5ZBNetSgHvZ wXBgJubto9Vy9GALfgHI8//RrYhVLnAPqHfUv7iODfNfmBArUTS7LljReCFot1ZKAvpI KQMrh9znBdvW9wpSPzujhStCvLLH08gBDx42Q/kyGrZ6DFNrsPsTaNKXTUPk9LY/kOw+ 3OnYd8b9n3dY/xwlUN37Re1D0pIb2HpGhpSAQYF062HoU563PV/yi3CdCrmaRoDi3XTZ LGDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=E6I6Ubn8kkAbTq6etV9iNCfegnB2Kdi4qPLvM99SBWI=; b=INjCCxyJ8L7HzwhzXr3xWL2UfRH6VKkYt8l8Ek+moSAAJCZEjwd7lGMhSUlUXLj/cN WULEsBjig/qs8Hzku8Rr8lrSW8V8M95NZ6sTviTFOwPO3VVJJzrV/MAchb1A0kVRSD1l /URIE16j8k83eO+yytds01WAHxIOVjpg2sRgBOOHmPXCtO4ITCTleIvtrxBDIrh7zHTb BT6l95Ooqgn+glTRzQi+n5Y6WWtM39GXj2ZWwgrflJOqkpB9mXSSYhDA95BlhM+BjE+F P7sGrOEVpEYxuuwAqi9WY+hCG8ON/68w/ZQiKlID2W5hRh4NJcAEjgh46EU1LD35v2n6 3pyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b="gQ+a9+/u"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OG2TLEZA; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ji7si26203387ejc.581.2021.10.04.11.40.43; Mon, 04 Oct 2021 11:41:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b="gQ+a9+/u"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=OG2TLEZA; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235449AbhJDR6b (ORCPT + 99 others); Mon, 4 Oct 2021 13:58:31 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:60162 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234961AbhJDR62 (ORCPT ); Mon, 4 Oct 2021 13:58:28 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 194HHFB4023925; Mon, 4 Oct 2021 17:56:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=E6I6Ubn8kkAbTq6etV9iNCfegnB2Kdi4qPLvM99SBWI=; b=gQ+a9+/uJHjBcej62CMcEHVDbFERGU9gvf7F7FbZge+kghhtDOb91O9d9qjAtx8umFZx w6m1PicevDCRNBQGkG5XA9/5f1c2+O0YMGnB7ouVt9Ckv/9ePB6FZj2PVjlevONRhJVx PcGVEFFdkSRkNuJYQrVdJq9PdjQ8BWaLOnlqlq0CRvDG4XVXb2NFS4tO5GHAbRUeZQx+ r28vBbK1WqN1LOO45+Qq/CZS+ZfETN6VvvrmisftKtlOf2ofO3//0WD+lF79HH1ZR39r SJ8F9+SzKTwTMuLKTwfXDGUqHOoR672wfA6xP54lnfN6GtNqMBBnC1wALLa+TgeYEkHy AA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3bg43gh8gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Oct 2021 17:56:37 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 194Htt8j126873; Mon, 4 Oct 2021 17:56:37 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by aserp3030.oracle.com with ESMTP id 3bev7s1faq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Oct 2021 17:56:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iiCBF6F6lGUcE9VdwtUOys8UORtYhKtmtReICrnTCRFTXXjELMybPjh0OxxvJSJzQSi8CUrADT2AcwbpOgFDSkljOgKEbFp7zvR1aVkwMXhjC3P+v4tRcu6SM81y4q96k8VGQcDrCxJ6Wghe0BFzFg+XOSVkEGoHKljCbnaVgbxJD6T8lfRWUJHzipO+1/t5UM0ZWPCfWRTM8+dXN4beGzHH7/dQD/vlFxhtVh8YBvJ4zDk4wX80kjiWC3aJKNCJVDXtTFV1z+i3u3wFLUYOHPGM46No5WJU5bITgtnfNw6dQolHiCVH0slH0190QsNmYIoSq7pMh09DcY4Zsb34qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E6I6Ubn8kkAbTq6etV9iNCfegnB2Kdi4qPLvM99SBWI=; b=eb0XOSBGkXvKmLqLCF/7I6/ppu6n0oL2RJtjVQC/jHo0JG/AhG61SO6lBMhBXO1nnnD0LlCg5ULbRglKuyVNY6z6axyaNcDLepBa3gIXZ4gSjzKE4aLFcW07S5YuTRLY6aw0R95dExi/zIe4QJWOjjjXZsmpCt2kVDUmikKG1JsHJXP+a/dZiZnPm8+Aac4V0qtdypnlej8tBQWExfJmEnaooOkeOY7jlDY6dGtu0XKaK0bLM/HtOkSZvan3rqvgxdGJHrqG7gqufD0h5j6PtY2Eevpqv/QRB11PQPY28wG1b0aN8BwBsumzqBPHgKmA/f1T95TvLGeinWfsb9QF5A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E6I6Ubn8kkAbTq6etV9iNCfegnB2Kdi4qPLvM99SBWI=; b=OG2TLEZAWOgeyNzBbsZiPU9AJWXR/ijlp6Ygci7VxkOeGiQfrH9m4j3XWcExxY39N+Y1NlByfHChnw+tR4G1CjXmh4idJXxhsp7flZCm3KjCFa67kKiadtibJTW8F+WhJsl9WpXTqHPeMmMtRbZ3DlsThOWT6hfzsQRr1afpI6Y= Authentication-Results: linux-foundation.org; dkim=none (message not signed) header.d=none;linux-foundation.org; dmarc=none action=none header.from=oracle.com; Received: from CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) by CH2PR10MB4278.namprd10.prod.outlook.com (2603:10b6:610:7f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Mon, 4 Oct 2021 17:56:34 +0000 Received: from CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027]) by CH2PR10MB4166.namprd10.prod.outlook.com ([fe80::2c22:7eb8:a2f0:e027%8]) with mapi id 15.20.4566.022; Mon, 4 Oct 2021 17:56:34 +0000 From: Stephen Brennan To: Andrew Morton Cc: Konrad Wilk , Alexander Viro , Stephen Brennan , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v6 1/1] proc: Allow pid_revalidate() during LOOKUP_RCU Date: Mon, 4 Oct 2021 10:56:29 -0700 Message-Id: <20211004175629.292270-2-stephen.s.brennan@oracle.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211004175629.292270-1-stephen.s.brennan@oracle.com> References: <20211004175629.292270-1-stephen.s.brennan@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SA9PR13CA0131.namprd13.prod.outlook.com (2603:10b6:806:27::16) To CH2PR10MB4166.namprd10.prod.outlook.com (2603:10b6:610:78::20) MIME-Version: 1.0 Received: from localhost (148.87.23.8) by SA9PR13CA0131.namprd13.prod.outlook.com (2603:10b6:806:27::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.7 via Frontend Transport; Mon, 4 Oct 2021 17:56:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef0efbcb-0aea-4562-2171-08d987604e06 X-MS-TrafficTypeDiagnostic: CH2PR10MB4278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?dkMmHQinfzk+h52vBD/j9Sx94A3iaan4IQCcGbziRk+t+8syhojoLk4JY/YA?= =?us-ascii?Q?p96geVSXxmVI8K56FHa2a8M3KGN0EqlK+Go4iwtokP2h0Q0+PCcg9sFCRkhY?= =?us-ascii?Q?MBdIVx4Iyo0aN+WZENUF0WMAZ1bTb7qELzsC7kzjl45/p8TQJIDMOoCakObR?= =?us-ascii?Q?IMIHGeFqt7rXkyN8+xLxmB7fcIALc3UIVZNxEyzLhFO+/9SLyazTrujG/3NL?= =?us-ascii?Q?Kyu7+L1xWoYLTZI6uqSXefWbGpZvD5zsjArGKfRvWPEZ8UbkX4Nluc9RjuGv?= =?us-ascii?Q?PDiqBfVq/Z5HSAatNF4Q34AAHgF+LmFoaXqViFtTrXw5NGMY9G02g9azs2lU?= =?us-ascii?Q?Bb/dvAehG0QmKeZj9ibxyIyRg7PLzApn/JuKmHTspLLqrrCdnHhiaixnD34+?= =?us-ascii?Q?374rUhg4tmjXD7T7AZkNscwteqj72HfS6wbyWsjgc8CavPlBBdQY8Cosxlu5?= =?us-ascii?Q?eHmKgX8aZAzftpkic0qGOEoFLC5rPopUCyclJ2aQiu9iv2HHA6oR+FmxSmnU?= =?us-ascii?Q?Vv68osg2ZWEmncKjZBMQ3cDcjzc8YFE0FS8u5ptB7RLOxLt80RbUaQPTPlbJ?= =?us-ascii?Q?9SSLmhW37aCXI7q8VUu2LtX8eYfmG2xjjH3kqZNgQYXjnalxGCrNPdI/LmrV?= =?us-ascii?Q?/8wR3COslt8Ui0ihxPIMIJz8i6oxAH0bqc5UdEMqqkVO0WmrxRD1YdtPEKUP?= =?us-ascii?Q?M7ZoIE40/0usEyn+ydPGgAw0LaD3tRqPV543XJoVtw8CdT3qS9+MQyXlfrw0?= =?us-ascii?Q?t7lx+EUul42dL4Z5Dq78JoGiaWXvhYy3+Az3k+gRA1KvuocIGG2r2N6k6ZqO?= =?us-ascii?Q?6+jzXS7Fja6evhZzsehhxR52rsIPJ6KCc8d6nmEm6bSRqCzjXvt5bZWYzlr9?= =?us-ascii?Q?28Uk77Fa5BWsMWEOoTDwauxDVyHkDfyb7rsFUI4PkMMoVvO1Xn2CqF4I7RWA?= =?us-ascii?Q?vMCqR6UepjZWwRSzUN0MvBzpiwZ6EDP25fWa+4WrPKey0BeKaCY8z3Nnhg8Q?= =?us-ascii?Q?3stosWPIqCo4avwQ89YsUBUN3w=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:5;SRV:;IPV:NLI;SFV:SPM;H:CH2PR10MB4166.namprd10.prod.outlook.com;PTR:;CAT:OSPM;SFS:(366004)(86362001)(26005)(1076003)(66476007)(36756003)(5660300002)(186003)(66946007)(66556008)(6916009)(4326008)(103116003)(508600001)(6666004)(52116002)(6486002)(2616005)(956004)(316002)(8676002)(2906002)(54906003)(83380400001)(8936002)(6496006)(38350700002)(38100700002)(23200700001);DIR:OUT;SFP:1501; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?k5ui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d2Do4A/99puRa+O?= =?us-ascii?Q?CnEg0lJnaQTpkgy9Vx2+m1qMQ9cCehH5U/2cK0/Gs8m42Shp/gW9Mv7lWl5w?= =?us-ascii?Q?yRepwJMHulXBU4rDDmQ1DuMheOM99XZR8njHu1iWFnH36KDcgUrPZ7SVbrol?= =?us-ascii?Q?blhl8oOQsmkMTd1+L4Npr/IROVnnxgdLqDVMhgZdZc+F3yE+P/Mjvw4c/p94?= =?us-ascii?Q?MUVL0G5bJXVAzhc4sSrwK04oA+80JOufJNEJh9hBjKqRoW+uT8G0kyWdVl5u?= =?us-ascii?Q?zoeIET0K8XpAZXZMo3NEjFXWLB5X6YDpfuwTiXzXmFdQDWljkwmiZUmp30hu?= =?us-ascii?Q?KKwe/gxoZJygVDhlKNZvF36QSCu5pLuvuaKKifRRJFMO3Z2oogRHX1qmw0vb?= =?us-ascii?Q?u20OIxxfZycyslgd9/XR/zkDPTUoc8mdjJcFAEawm9Q1CXp+K6q1E4Qz41nd?= =?us-ascii?Q?iP1NdBknNQHoG1sOHjHLDBjd?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef0efbcb-0aea-4562-2171-08d987604e06 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4166.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2021 17:56:34.6833 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LWZs4vWtkrYV25WG4NPqqr24Dk0FJ24iTUN/XYePWmsvhYMNEt4lf/UldBboJ1HFwpMV69+Q9mn5J0xw3E6HdNZyR/fuMFRfJpkHKIiSO30= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4278 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10127 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 mlxlogscore=607 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110040124 X-Proofpoint-GUID: Rdcs0Jn-o_01l8qR2ucbQ7eqcYFUbHmk X-Proofpoint-ORIG-GUID: Rdcs0Jn-o_01l8qR2ucbQ7eqcYFUbHmk Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pid_revalidate() function drops from RCU into REF lookup mode. When many threads are resolving paths within /proc in parallel, this can result in heavy spinlock contention on d_lockref as each thread tries to grab a reference to the /proc dentry (and drop it shortly thereafter). Investigation indicates that it is not necessary to drop RCU in pid_revalidate(), as no RCU data is modified and the function never sleeps. So, remove the LOOKUP_RCU check. Signed-off-by: Stephen Brennan --- fs/proc/base.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 533d5836eb9a..3042ab418c31 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1979,19 +1979,21 @@ static int pid_revalidate(struct dentry *dentry, unsigned int flags) { struct inode *inode; struct task_struct *task; + int ret = 0; - if (flags & LOOKUP_RCU) - return -ECHILD; - - inode = d_inode(dentry); - task = get_proc_task(inode); + rcu_read_lock(); + inode = d_inode_rcu(dentry); + if (!inode) + goto out; + task = pid_task(proc_pid(inode), PIDTYPE_PID); if (task) { pid_update_inode(task, inode); - put_task_struct(task); - return 1; + ret = 1; } - return 0; +out: + rcu_read_unlock(); + return ret; } static inline bool proc_inode_is_dead(struct inode *inode) -- 2.30.2