From patchwork Thu Sep 7 17:47:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13376732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E468FEC8726 for ; Thu, 7 Sep 2023 17:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B92468D0003; Thu, 7 Sep 2023 13:47:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B426C8D0002; Thu, 7 Sep 2023 13:47:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A09E68D0003; Thu, 7 Sep 2023 13:47:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8EC7A8D0002 for ; Thu, 7 Sep 2023 13:47:22 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 643241CAD3F for ; Thu, 7 Sep 2023 17:47:22 +0000 (UTC) X-FDA: 81210533124.16.FE7917F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 298F01C0021 for ; Thu, 7 Sep 2023 17:47:19 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NcXGBCh5; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694108840; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9FU0HDBbS9848C77tpg24Iv2uyZEtVXyAgpiQsjv/fA=; b=yMp8IvamdVwHA82e4SzOLf+W9ZOEFG+grqlgKIxizb+4jN/LUpGR2cDwqSHlD9uecf7cjz 4GhAUoLL28LzbcPtpvX6Z7MSgbemF1LORldEQfN7v3ziTnZNYFzl6zd7c3g21aSP11oPMR gb6BExeMV8NBGC6eXE0MUP4t2BmizHU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NcXGBCh5; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694108840; a=rsa-sha256; cv=none; b=AX2nH4cFhttO/KVOwqHBxRctk7UwFFeJ0TvTWjOp1YbD4hA9hIEedKaxGmWYa3LFaT4bzU e5vWOxTvdJizUzfW9AYQOapvSbKq+DjZ//HfsYn4BiC6t+AC6+v+28pzViPfyHwbJx2iXQ LpWc/BOricWIGLlUc9sdoFJTUR2mKDA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9FU0HDBbS9848C77tpg24Iv2uyZEtVXyAgpiQsjv/fA=; b=NcXGBCh5BPyjAcESrPbWgrRsvW PDdtlXUAW0k8lC/IdN0FAJeBK1laH7kwHd4DLz5VGxpxlbeGjY5LEWxmT2mnCzfiDg/9MxX1y9YIq Aco2rxkVPG1Q5cC4t6HrgpCG7dzJ/n00GBBB5HYp+YIDycwMRJ2stN/4f6UCE/cu+yDvEPg/xymUe gxLzC04nT4WV/5Np19ENi1c6ygMEpl7CoMfjbF6CfUeB2VJ80U//JUdE1S4mVgoEnKU3m4Us/q4ti l2voBmp7JV5jVnAX2/7wySndJLGXrAMrdqgKY6dmc/C4GztfYiBEY6CBASMTB1vOnuCu23xjQCZ8Y 6X3U3qxQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qeJ5w-00CUFT-91; Thu, 07 Sep 2023 17:47:08 +0000 From: "Matthew Wilcox (Oracle)" To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chandan Babu R , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH 5/5] xfs: Stop using lockdep to assert that locks are held Date: Thu, 7 Sep 2023 18:47:05 +0100 Message-Id: <20230907174705.2976191-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230907174705.2976191-1-willy@infradead.org> References: <20230907174705.2976191-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: o8uw798syqac9tzf768yuwn8m86ywtc7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 298F01C0021 X-HE-Tag: 1694108839-862258 X-HE-Meta: U2FsdGVkX1/gE6DK3MmoG3XZN/RrR7d78Lz9c4UOuTGQ6RnprUpC+fc2zF1sJPdC47Q6FHr+mOeBydcr4tEhNvlBjrWDa6GV/NMdnUit4G1t6mLjW/zr949e3fAfSQKD2Dk1rREK4283d5QpsczpMgognClJs1sihFj+07vkQ7I0f+IEnBrbcOidu9dYh1WARTCIES7DviRkN3pmZxs/ajSIlY0ZZURkV8p9kme5ASbYX3vro7hjP8MeflbjMejW9tEEAPtbl414bwXIPfu3T71XBDMiOv2ukUiuznbNG3+fML2nEJ57l1GP5U5W/Vl0hZ4szRzBFksZk+p/ojLaeGJNR9tx7GwOLywGmMTA/+vEjE1a0aI7NDEhHzgrGTaYajTLqoafCbRRk7pGkR+HqyjhjA78xwgcxM6FrfbSrOsvuPiduDEUFGH/A2ubZoiYMEewP7r2JdsUGBsJCVBLADRWH1DR1Yof2gn13bHmccGNZms67njWlkzOTgPeUVthCxLebk5wymKPpjc69W+u3x5X2tRhifbrMq6HwMoir1/q6/1kgy8BRZMIcrhWSL9SSgANHNHOaxQTkuSEjO/kB1lNdW2DwWXwT0aZw0jForcC3aYrnwILuOPUbAE2bR82E+CYDLkrvz+LE1n1BidYXWWCab8nOZNG3kgSIYpuEY/LWuDedbFiLum/hiuw4O6ZU595W4YmD1aHDXKxh82+hl1Mu8GxFPSk2h3iuQ4YQ6LKpXZDnDfGAZXnJ9JWuKe3CN+r+pJeuIbeQa2AJQmnUWhfUhn9LCQK7PsKDuKW2vSO+/PCaE7aO4PNFSVbwgGwNB4lastebSz+Mq2x2jlpZaFw64ofvYB6paSCcCwOvD7wMQOpI7d3wEZXulfeDFbwI/iXb6QLxKdJnYrQL4wZvB6E/hXtT59xRhz0Zizf7udLezUGalzrb6OIck/DiezPkfRB46IXTSf7qNiXiQa uB93NZ9L fgbS4gwdMqfteNm2zwKCyJD1g3lAgoL9+KZ8cl4mKpqUxxTaEcjuXg+/PHBAn7Lqraisa4HUQmCxlODIE9r/QFVs1j2BxorXb6IPczd75Mx/695+QTKSerQcnMmn7cN6Agg52QYGe6R6tUQqaMZvH296t6IouxDf7kPHyjLc4P+FVntf/RqiqT6hK5Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Lockdep does not know that the worker thread has inherited the lock from its caller. Rather than dance around moving the ownership from the caller to the thread and back again, just remove the lockdep assertions and rely on the rwsem itself to tell us whether _somebody_ is holding the lock at the moment. __xfs_rwsem_islocked() simplifies into a trivial function, which is easy to inline into xfs_isilocked(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/xfs/xfs_inode.c | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index c3cd73c29868..81ee6bf8c662 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -334,29 +334,6 @@ xfs_ilock_demote( } #if defined(DEBUG) || defined(XFS_WARN) -static inline bool -__xfs_rwsem_islocked( - struct rw_semaphore *rwsem, - bool shared) -{ - if (!debug_locks) { - if (!shared) - return rwsem_is_write_locked(rwsem); - return rwsem_is_locked(rwsem); - } - - if (!shared) - return lockdep_is_held_type(rwsem, 0); - - /* - * We are checking that the lock is held at least in shared - * mode but don't care that it might be held exclusively - * (i.e. shared | excl). Hence we check if the lock is held - * in any mode rather than an explicit shared mode. - */ - return lockdep_is_held_type(rwsem, -1); -} - bool xfs_isilocked( struct xfs_inode *ip, @@ -366,15 +343,14 @@ xfs_isilocked( return rwsem_is_locked(&ip->i_lock); if (lock_flags & XFS_ILOCK_EXCL) return rwsem_is_write_locked(&ip->i_lock); - if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) { - return __xfs_rwsem_islocked(&VFS_I(ip)->i_mapping->invalidate_lock, - (lock_flags & XFS_MMAPLOCK_SHARED)); - } - - if (lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) { - return __xfs_rwsem_islocked(&VFS_I(ip)->i_rwsem, - (lock_flags & XFS_IOLOCK_SHARED)); - } + if (lock_flags & XFS_MMAPLOCK_SHARED) + return rwsem_is_locked(&VFS_I(ip)->i_mapping->invalidate_lock); + if (lock_flags & XFS_MMAPLOCK_EXCL) + return rwsem_is_write_locked(&VFS_I(ip)->i_mapping->invalidate_lock); + if (lock_flags & XFS_IOLOCK_SHARED) + return rwsem_is_locked(&VFS_I(ip)->i_rwsem); + if (lock_flags & XFS_IOLOCK_EXCL) + return rwsem_is_write_locked(&VFS_I(ip)->i_rwsem); ASSERT(0); return false;