From patchwork Wed Mar 27 19:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13607298 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 E4EE8CD1283 for ; Wed, 27 Mar 2024 19:07:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6560E6B0099; Wed, 27 Mar 2024 15:07:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 606346B009C; Wed, 27 Mar 2024 15:07:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F5776B009D; Wed, 27 Mar 2024 15:07:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 32C3E6B0099 for ; Wed, 27 Mar 2024 15:07:06 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E87D01604D4 for ; Wed, 27 Mar 2024 19:07:05 +0000 (UTC) X-FDA: 81943751610.22.E9E0C05 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 3D1CC180009 for ; Wed, 27 Mar 2024 19:07:03 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=f9Ps6WFN; dmarc=none; spf=none (imf06.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=1711566424; 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=HE4R/UvkYOa8188f7Pb6pC+u205ZUyXZ2a+sPAh00pY=; b=pQxKc0IADBIuEL8TLHVV/Ls7ht/OiNh33zQ/h30Jj/m/JhopyXBJLk4CiS3MIp0QIgDIkb FrKKC80NcuirHtQRWcu0mP/O3BjrxhsIC6J1Y3Qb+aeM1kk8fz7HQ2ul894Ey9gYeYsscR 4qSigpEw/u52FOm1Yo/jsub6wawjKK0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=f9Ps6WFN; dmarc=none; spf=none (imf06.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=1711566424; a=rsa-sha256; cv=none; b=SqUzTFJw2Tl024YFDyOYgzO9usVhjNc74cMWhiW6fDSnAy6eNjiP4Qb7mgles9cBJyRBIX aqjuyOeaipZvngZAgoje7v3tEWwiTkyHORS1JVahF0DM2cXkFgbjK8kEmRNveM7PN1ns5G jB5abFu/QK5XHFnGgjTVEui/kPdPn0U= 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=HE4R/UvkYOa8188f7Pb6pC+u205ZUyXZ2a+sPAh00pY=; b=f9Ps6WFN0cCFy2N04dn30bDoG7 Idiepm8ExzOBscaO3ED3kwsWbFFGKPh+dzEWm+6fSGCmK6ohgHm+nqGW4mz1cqKtnA33zNFZwR3Mx h3lP4ntcE4VHwxPfLO2r2lxv/wQlptPYFIdWmUsin2q8xBemuylWOWEma1OdRTNBiv0+bTyQc+mKi Sy7Fw+ZELTYb+ybhyQuvxXY6Entihtpz7zoAa+gZhTIFPT8JWPnI6U4NnqyoY5CbbNQPVOXCmdC0a RlamvoG0pei39gd1tfPXltY8Nb5/hB6mdQ7GWWPwNThDgB2NeyrUg2Zm+E+LgGMp7tkHMYlXC4jyN zRhtXtpQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpYc2-00000004Xd8-3TRh; Wed, 27 Mar 2024 19:07:02 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH] mm: Use rwsem assertion macros for mmap_lock Date: Wed, 27 Mar 2024 19:06:59 +0000 Message-ID: <20240327190701.1082560-1-willy@infradead.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: jta4fokxa9e6rsoy5s5chjf77i98yjuf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3D1CC180009 X-HE-Tag: 1711566423-888504 X-HE-Meta: U2FsdGVkX1+gkI9Spa7uDmneX0R1as8+AYy8ati7VMHyuLcUaT+tclba53e2TCDN2CyeWlWVWM/Dbv84wCNpNwUENqu2pQDrsUpvsFZV0dKcLa69lTe3ss6LJX3o/C0r8oPJYGhgli1WQjK/hmJQDhbnHB9nmGmXQ/YahH8i1uLlCfjXpdE0g6HK2DmCEso2tdJc9eegqWga/NwWRawN2e7EdFVW2jhxyghsJ2ay96SJXQsw6Sa4cvIEfojE7fd6QbimacTwbnaSPsCIexG50RF3Rqb1uSJu4qUiZ5wr9Vm7+iL94FdDRs0e4lGb0yS6HXe8CIsh0328JIpnhgL7bgmJbDCW15UdoK2qn/iNg8LLXFLqbbVjabq62HqX9gslZNKIjNkoR/RSn5F6qirCM5KlVc2Qq+0dx071izrmcR75DfFn1OXb+TG5IM9qtVs/+i089k1vLkQpEE6WuDarqoi7+g/RfK8yWnQnGUO68J8uc7YtAvMO7RZpkq1zRWr69+bWMu0CjbJtcLgQHc8qVUXpmQT9lun6BGedDDsSf3Ow9BoKha0hKT2SFAURIt0lIJJd0LH9LauIWAQD385jbNw3Eo0D0xlQdJjolB9Qt65uIa+O+UbuLaglp2rFvNVrZmIvywxiyEkmd4tZQzGaKryR+2DkAq9MohIjIjcA4YbosDvc1QnT/5m3XRfkxDi4WnSSbWXqqF/XgVL5uLg0SIKLBrrmORxwRVwJ/oSUie3ct5v767P7XjztfPRen22pt3wV+kxirn1y0ki4BicDAznCzU3EVHRLJ5ogCCtHe3UZlgjCOBAS7cXbyx9pASc0L/W1NyOGsG+LMQWGr2FAmpy1td+mNNohc0cweeYL+Yi0ysEHa0noN9n2NOLUnT7JILo2v3R9pCsaKcvwNHt/YxPptw/3+Fsy2JgUMhQLwmIar82TyBKBcMRZaxAI4P4KlejDNz7egLW7RNQa1nZ oq8phFg4 6qhSM7BYnqX2juYHSyHnOGcmPVLmKIehBTiaZdw/AZDejONlt1Ay4MMRS+6COTxSzQdiTT32Xyafa+nXluwtDDGsYBUV6/Vpnh36PfyBErSXie5feNwwKgXau79lIkYKakLQBqYRlRP1mcr4oH9fxfmAB3en0xMt8i6lxAyHZmgvVMYIbSdF2mHeljm7rDw52b1john9ssOVKXl0KgwadYZ1i9OQ8koblrpU/ 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: This slightly strengthens our write assertion when lockdep is disabled. It also downgrades us from BUG_ON to WARN_ON, but I think that's an improvement. I don't think dumping the mm_struct was all that valuable; the call chain is what's important. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- include/linux/mmap_lock.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h index 8d38dcb6d044..de9dc20b01ba 100644 --- a/include/linux/mmap_lock.h +++ b/include/linux/mmap_lock.h @@ -60,16 +60,14 @@ static inline void __mmap_lock_trace_released(struct mm_struct *mm, bool write) #endif /* CONFIG_TRACING */ -static inline void mmap_assert_locked(struct mm_struct *mm) +static inline void mmap_assert_locked(const struct mm_struct *mm) { - lockdep_assert_held(&mm->mmap_lock); - VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm); + rwsem_assert_held(&mm->mmap_lock); } -static inline void mmap_assert_write_locked(struct mm_struct *mm) +static inline void mmap_assert_write_locked(const struct mm_struct *mm) { - lockdep_assert_held_write(&mm->mmap_lock); - VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm); + rwsem_assert_held_write(&mm->mmap_lock); } #ifdef CONFIG_PER_VMA_LOCK