Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1133247rdb; Sat, 7 Oct 2023 13:36:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGPiynL7x8WBbqS3KCneTrsG+jmnq48k/FfuqqZFmtNbLXoWRszs4MfL31OhgwltOaQQrWm X-Received: by 2002:a17:903:32c6:b0:1c4:3ae6:381a with SMTP id i6-20020a17090332c600b001c43ae6381amr15173815plr.0.1696711002866; Sat, 07 Oct 2023 13:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696711002; cv=none; d=google.com; s=arc-20160816; b=kNqJ2/aNdCWbvWnCDtBB8VVi2/SLdmJUZU3tNKRqBw2EHuqnNN2+azkKlFnmdY2Yue Kpgki4fJ0EoYsWyAJQ7v+scs33thwPbn1GhCKh6L38nlMJaIXLmGCvoCjMJf3ucMnFYn vzKqqJRomMLMCTcFLNpks3k336VhIvl8cQFcP7mAQjV0tSNEZ+uNKV3u3KqM2/ZcgDs/ KULcRnhhFAzu2hPtYW2XqtxHGATgtqpcqQIs0E5/XdNd0YuxTaCXm03Pu666jaTvBizU tiMdnU0o7Ltdnaq54ndBtGBsk28cA+e8rsvdeBplUSK3PSExuRNiru6og0NS1kUAJZSU tuHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=TF/aqVn3IrPnAMqnSHzChnQi0apaIvuOdxt0Uorvv1E=; fh=xOXdQT4SsuXIFM5Yjo81cCn92/LeCLHKO8ZW4BZqIMk=; b=HONUFb9B+uqBzWRKJY3Hv4kit0D57XtrrqL7odCS9A+B8dxcv9zcE4WH47+cDvEhae DUIK4Pk7ee4UZPTPEj84RfC1z34KcC9UtpbX2E/GWwOseQvnwR7vkcEiZCTlfNT/yyG3 xCWg5lPNL/r7QXeZpTioHuWzKYgyeyQ8fA+vdGWQpSmIoctoOKwiX3fDj7fICAn2dNuM g/iYZ3U1ULb2rD56jOgDmicmM/BSmqaHAvlX3rlXSV6tAotC1oTwPLs2VtoUe+NDyBvX 00qtDqB0DVXsQTj31B2rJQa0EM7nf9tmRMnivtlryoQ3tutqhpL0Z3jZye0seWCo0Nac SbAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=D3iwRI4G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id u9-20020a17090341c900b001c5ecff1bd4si6875558ple.603.2023.10.07.13.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 13:36:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=D3iwRI4G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 98F4D80BEF04; Sat, 7 Oct 2023 13:36:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344176AbjJGUgG (ORCPT + 99 others); Sat, 7 Oct 2023 16:36:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344124AbjJGUgC (ORCPT ); Sat, 7 Oct 2023 16:36:02 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4FDE95; Sat, 7 Oct 2023 13:35:58 -0700 (PDT) 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=TF/aqVn3IrPnAMqnSHzChnQi0apaIvuOdxt0Uorvv1E=; b=D3iwRI4Gvzv9R9HV3nr9SWYP+s RdPiYvPHnG64BZK2SzCbvTwNWhcnYMlYkwGALT2aEiqtaKZnaCALWYgm0MWGHhD8oGn9kfTF9enem NetzCtD4xQREvOZ4jXL1aTsL1kWhwbRLCsutNPGYwtaujQKRGRamU/XdZL7b+i+3btAl4Nm5skEzP ccJl7S82yyWJeai2rto3f8d9OiLsOTr2b+52aFNSjCREUH4N5WFYLQTTKEuXsXa4w2ePNoq+3VNb6 hPZ6INb5AhYpZv2WUlIReGB4xllPL/lkJNpE622MtUYd/2QyD+lZ4IjBdOp7cZYtwEd1wxCoLiq2/ nmbReRHg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qpE1Y-005mL8-Eh; Sat, 07 Oct 2023 20:35:44 +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 v2 0/5] Remove the XFS mrlock Date: Sat, 7 Oct 2023 21:35:38 +0100 Message-Id: <20231007203543.1377452-1-willy@infradead.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 07 Oct 2023 13:36:38 -0700 (PDT) X-Spam-Level: ** 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. 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 three use cases for now and we can trickle in other improvements through other maintainers after 6.7. I'm sympathetic to "this will warn twice and dump much the same information if you have lockdep enabled". Perhaps somebody has a suggestion for not doing that? Matthew Wilcox (Oracle) (5): 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_locked xfs: Remove mrlock wrapper fs: Add inode_assert_locked() and inode_assert_locked_excl() fs/attr.c | 2 +- fs/namei.c | 6 +-- 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/fs.h | 10 ++++ include/linux/mmap_lock.h | 10 ++-- include/linux/rwbase_rt.h | 9 +++- include/linux/rwsem.h | 42 ++++++++++++++-- 31 files changed, 142 insertions(+), 203 deletions(-) delete mode 100644 fs/xfs/mrlock.h -- 2.40.1