From patchwork Fri Nov 10 20:41:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13452786 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 9769EC4167B for ; Fri, 10 Nov 2023 20:42:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22062280009; Fri, 10 Nov 2023 15:42:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AA268D0005; Fri, 10 Nov 2023 15:42:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04AA2280009; Fri, 10 Nov 2023 15:42:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E3DAE8D0005 for ; Fri, 10 Nov 2023 15:42:53 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BB60C8031C for ; Fri, 10 Nov 2023 20:42:53 +0000 (UTC) X-FDA: 81443218626.22.AD6CC22 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 314524000C for ; Fri, 10 Nov 2023 20:42:51 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NoEns8Bo; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699648972; 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:references:dkim-signature; bh=C5X6/h3e8eaTCuBQ6as3UZr2CNlaSfB1exmIWSz8Szc=; b=VhOEX4hPbu0NeqmDFvbxvGK7rtTkOoGDmKeCsuWbymIfbWR9tP+JPwkY3MtMcKJULDL7WE 4nHwltF/ODvwd9WnPLmOBF3UA5Z+/gMXrLm+RjUVMr+yfKvg6O7str9tMfH8xSXfatDFQu 5AMcICLPCrdOgWCges8cHYdGxYrTfko= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699648972; a=rsa-sha256; cv=none; b=R1MNGlJD9g+8umKnH4qZYAboyGdD0rw6gMSVLsq0DL/OIReZz0gW5TB9y3fJXkRiOcTLtV WeZ1od7O4+Ov87SKilMFKYMix/xwxJK1HBfRL4Q8xowTamO4Li8dJU36jbiU7OdtU6hizr vl7aDP2Cgel2duSSfkq3QHCDut4NQZI= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NoEns8Bo; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=C5X6/h3e8eaTCuBQ6as3UZr2CNlaSfB1exmIWSz8Szc=; b=NoEns8BoaQo66ULG0gb9rTeN1z gT+8MQoAuvTFxX3VYSOZR0e5qNZT4DIQl11LmO6Dwnnaz4ZWjbraCKvJnmca7rbgDyVTUvavaA2ZT pYhaAkn77e1Q2N8IDc/7XgiKLLhispH7ai6cMg4kjqiHqujdyX+/sxEmJ6fmwgcn8NemuLX3orgDU bkj3eKBuKk8yaZtyx25FV9UD7V2jdz6OAFOVUwazBSlRiqKJ/nIzZNGiWTjgkUCs/Dpq0Vz9AfwxA xARjgSG5TV+TFK3Uo/R0D9lDt8FGQzC1mxgNnVnslUKrj8skPZ9w3IyKbv0Xjsxq0eVV6FvtlClfV LU/LcCcQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r1YJc-00FUT2-U3; Fri, 10 Nov 2023 20:41:20 +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, Mateusz Guzik Subject: [PATCH v3 0/4] Remove the XFS mrlock Date: Fri, 10 Nov 2023 20:41:15 +0000 Message-Id: <20231110204119.3692023-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Stat-Signature: yoee1ohbi9qjncmdghudeok8m17s5qdb X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 314524000C X-Rspam-User: X-HE-Tag: 1699648971-698949 X-HE-Meta: U2FsdGVkX191Bjz8X/4XSi/dotXF7jpWIFNylh+NBbq3rt8BdDBTgBmHFEXcf/fdklfkxrbIeRGpbx4ZHPTQxUOmOqJzX2Ur/D7EqKqPoGDGuXrOfIMRREe8u8V3PnTdwtD6oOwrZWrezKk/vNH0oa9sgh69YnKTDEAkncAGidbnSpfZcmoROtbmfStjbK7zDy/CCMq2/txU1MhLajWnYxtyf7qGIEqBcfuMOlXNz6f9fQAGF3DAykRlXHk+WiEd50hjDcE2r9d1Tk8433lIl5IbtoNmfqmtTHmoVWYRaK0tpPutqd1pYmT952VXNt6uoyKC+WrdIeLxEIYdqIBJuXUL650a3ZkuhdrLaTec0AWWPpV5xwQT5LtaZEbM70C3gxsCGMGilvEeYr6zGfCUYmZlmyGASOrz6oEH/6G0liKqjEtDwp67t5m96IcZ/SPMs5EEZSo2O/eul5BAJhAXT6x4TIRq412jrQNHZJqqFu7RPoBZFTdoil2HJ+uDiqre4H0PX5urNDd9IDe3/XV0uG/mjXnrYp+qtFfipcRMGwWro138Fiui+nCetvOT90xroviBXzC+onZA1OdKvjFfCRT7bqLEB4D5ythtTFSsut64MwmWG0MQlglndQi8+Fs2teN7Yo2y+XiKJFdSFP5WQulYLY0pUHXQdpYg9RgLJhyhYBJJ4krUPyBdNwesbsNd1yw/Ebo1HomotZ8m27afV5QClSuLakMCfsA/l2DC47smpFqdh9oF6n2+zEsHciO54HYElIJzGspA0UlmiDRz9MPW9xjpvRVMT4+mcRJfNvVW/H01NVOElR9VGtf8Ch3sZQKrWLdAQm+y52YQfyLfCcGvbs/c752XAS9qeUD47yOeHa68caepNUTmZU6T1B05kTeKHOM2k1yeQyVpeFNZZQ6EcG0Y0rM0MTGpmFM8xXz/4fBHklQYruGtKQnS1UOp/3ezzZ+1TmhOgifqYHD n64rRtAW sOSnm/On8GGBS+Jvq4etqmxXyk/iZBF8otedewU569vRoXkZYWKAQbvdslHc1aRPdRR1D5cUqv+Kjn5C1vW8+qD9yzG0oTq2FqQmp75RH7oRe9Oihy4tWDogu4Q== 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: List-Subscribe: List-Unsubscribe: XFS has an mrlock wrapper around the rwsem which adds only the functionality of knowing whether the rwsem is currently held in read or write mode. Both regular rwsems and rt-rwsems know this, they just don't expose it as an API. By adding that, we can remove the XFS mrlock as well as improving the debug assertions for the mmap_lock when lockdep is disabled. v3: - Rename __rwsem_assert_held() and __rwsem_assert_held_write() to rwsem_assert_held*_nolockdep() - Use IS_ENABLED(CONFIG_LOCKDEP) to only dump the information once - Use ASSERT instead of BUG_ON in xfs - Fix typo in subject line of patch 4 - Drop patch 5 (inode_assert_locked) - Rebase on top of xfs-6.7-merge-2 which had a merge conflict v2: Add rwsem_assert_held() and rwsem_assert_held_write() instead of augmenting the existing rwsem_is_locked() with rwsem_is_write_locked(). There's also an __rwsem_assert_held() and __rwsem_assert_held_write() for the benefit of XFS when it's in a context where lockdep doesn't know what's going on. It's still an improvement, so I hope those who are looking for perfection can accept a mere improvement. We can do more to replace uses of rwsem_is_locked(), and I have a few of those in my tree, but let's focus on these two use cases for now and we can trickle in other improvements through other maintainers after 6.8. Matthew Wilcox (Oracle) (4): locking: Add rwsem_assert_held() and rwsem_assert_held_write() mm: Use rwsem assertion macros for mmap_lock xfs: Replace xfs_isilocked with xfs_assert_ilocked xfs: Remove mrlock wrapper fs/xfs/libxfs/xfs_attr.c | 2 +- fs/xfs/libxfs/xfs_attr_remote.c | 2 +- fs/xfs/libxfs/xfs_bmap.c | 19 ++++---- fs/xfs/libxfs/xfs_defer.c | 2 +- fs/xfs/libxfs/xfs_inode_fork.c | 2 +- fs/xfs/libxfs/xfs_rtbitmap.c | 2 +- fs/xfs/libxfs/xfs_trans_inode.c | 6 +-- fs/xfs/mrlock.h | 78 ------------------------------ fs/xfs/scrub/readdir.c | 4 +- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_bmap_util.c | 10 ++-- fs/xfs/xfs_dir2_readdir.c | 2 +- fs/xfs/xfs_dquot.c | 4 +- fs/xfs/xfs_file.c | 4 +- fs/xfs/xfs_inode.c | 86 ++++++++++++--------------------- fs/xfs/xfs_inode.h | 4 +- fs/xfs/xfs_inode_item.c | 4 +- fs/xfs/xfs_iops.c | 7 ++- fs/xfs/xfs_linux.h | 2 +- fs/xfs/xfs_qm.c | 10 ++-- fs/xfs/xfs_reflink.c | 2 +- fs/xfs/xfs_rtalloc.c | 4 +- fs/xfs/xfs_super.c | 4 +- fs/xfs/xfs_symlink.c | 2 +- fs/xfs/xfs_trans_dquot.c | 2 +- include/linux/mmap_lock.h | 10 ++-- include/linux/rwbase_rt.h | 9 +++- include/linux/rwsem.h | 46 ++++++++++++++++-- 28 files changed, 132 insertions(+), 199 deletions(-) delete mode 100644 fs/xfs/mrlock.h