From patchwork Fri Nov 17 14:51:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459011 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 B831CC072A2 for ; Fri, 17 Nov 2023 14:52:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD11F6B04D8; Fri, 17 Nov 2023 09:51:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C57936B04DB; Fri, 17 Nov 2023 09:51:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A57506B04D9; Fri, 17 Nov 2023 09:51:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 907BD6B04D7 for ; Fri, 17 Nov 2023 09:51:59 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 621EB80DB3 for ; Fri, 17 Nov 2023 14:51:59 +0000 (UTC) X-FDA: 81467735958.15.01D49E1 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 4F43918001A for ; Fri, 17 Nov 2023 14:51:57 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HE2i7bgW; spf=none (imf24.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=1700232718; 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=2TYOXhkj7x810xSAvtF/cEDHanY3PKLSEl1T1XfqudQ=; b=Wxp65pWfVcNojjxsftjtO2EqmElARFE/tPgU1NWZns5ami/GkvifKG7l4ZDVI57OlvhwAH XEzlbBCnUtRkG73Ei3sbfXU4t3qq3I+jtJ+f3jDCxNZXAmahPE6ZNCoH2bOHXF+DMuiz5u ste15QPetoct5/xk8D4K+4Eg37640ng= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700232718; a=rsa-sha256; cv=none; b=1J16Hh4VY7hgKo4f1E6qb3lC3DpMCH00byUE+a7ssEVLYAQ+599UvvWRCRR1+JMFO7fiBR uFJP6/ieIHsPdH6LJYrGJFA3UdyRIrhmvoaHGKKoIE3Q2LWkcXVoJ0zBKe4Fy17bhxI1Df fr759Vj1LrnpLsVEK+JLzgS/50ljALI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=HE2i7bgW; spf=none (imf24.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=2TYOXhkj7x810xSAvtF/cEDHanY3PKLSEl1T1XfqudQ=; b=HE2i7bgWmXkvnGMiC2WxmSINb4 WgtCG1DWJzcf7S5/5voTzZGEGGpvpG1RqU4A+7g/P31+BfR9Ze2vhNig3dYRj12T4JxReB4plz5Qs +Rizm2+s0gMQVgduPywu/k8AeYVTuoFci2OuU9zNtIpgp04bP9HC5/lDLuErLTr11oX7gkpXXriB6 GptH7Ybsb2BrkyyvzFQXtBXWarB5X9DmZp8evq72IorijZljcKvJxMUI/9bG2Vew+IqjvbLtZV5N7 fQkgNmTXPHqHodR4hn4Z0i4mfykEx2ODv78iDGXkx1jN1Jlk0YbA6C9kxAcRufm0tPH1UTU5FpUXL m4hTsIWw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r40C7-009ypt-Ib; Fri, 17 Nov 2023 14:51:43 +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 v4 0/4] Remove the XFS mrlock Date: Fri, 17 Nov 2023 14:51:38 +0000 Message-Id: <20231117145142.2378800-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4F43918001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: rn5o6zyir8jkakm9j78m7h93nnu6175a X-HE-Tag: 1700232717-890692 X-HE-Meta: U2FsdGVkX18wJkRJmZp2+tzFVsRp1he+e1Au+U/ViVeOwFWs8aOZNlpU9tWE070+//ymddfty4FUouKoVTbSXY7F6EX1LRk8YmLB3Yy6Bb0wMSIkmY6jOZ/tv9LIjwYIM2X9NP/7QQLVnLQregwmhLiYT7NT/fI9F8YW2tmM6utm8JoH3kU56KtsXkEgYIA4nliKgw+BSqIfpkFKMaH6cXBcQF7NwzdM0XCykwD4qQbWGT/01dHKeKgUIQJQp3PiYZuK9ueyWk6qZayKy/gk4Hx166DZHDp5MNv/cjSsJcE3jAutCOP+FCIlnl1zDm2UXmEw6qlXfQYwkxaYb9vpIAgY/GHUnLKkHdP0GgQ3TgfJe+uRrgNG2ZIcvBv/nbTK6ygGCYD4lz3cer433TC/OlCYrVAKqMURi2+WQlJv8ekM7C0pa1DOYQJme3qs9WFdsBHg/Z3RhUhrKH8vPioCK55ivjv8WCA7i+c0oSAb8ycuTiqLpEwyhMA21Uv5c9+92wB4zsTJ5rFnE/wY/Qes5mMyHater4FyhIQaarcjJjpLRuNshLyKXgK79E6njwPxdbooDxBZPsaNsLG7W3QfBfavAxIEEMrkt0gAEkY2HA+u2NZ0+l8jyA0k4dS5G4hbIO6ZVo6+QJwFzk3diKEq9cr/FA9wzF1aDgx8X8+cCZxOA9Pr5o3u8gYSr/TbaS0cKlBotz8qRW0YIRTbBAGCeYqpwiU7G0lPHDkK5FdRLdtmxvt2pW4BeO/qKKpXYBGvTuMcem0VSonJ68oFOey6MzKAC90RICsZkHUcXq0WBlsb2P56oJ1qVDv8VaN3rGBXA817tiMEDvqKXmvn0ef+EVyrW5/gdQ8sNSZGIn3urg0p4xSnsxAU25pL1/9SlJsiSTuI6n9xoAZw5EzPl7AgnaqV1drH84Ew5/ipgVTzl7hRLRV7H03/i7Yi0w8i8kMuifgOTshCBmnBKCmJI+5 UutnEskj YBqhAucwK113HwUicQzfQEblGulMbkl1Tw5djjYJ+vT1G5Ex1D35xzXh89i3MO14+wkGusKwd3VGT0RSlWx1Uyoqvj4MQykoMQ1D2oVO7lC9BGSIm4mI4+btaug== 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. v4: - Switch the BUG_ONs to WARN_ONs (Wayman, Peter) 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