From patchwork Sat Oct 7 20:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13412480 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 496BAE95A6D for ; Sat, 7 Oct 2023 20:36:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D13D68D0016; Sat, 7 Oct 2023 16:36:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC3E08D0013; Sat, 7 Oct 2023 16:36:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD9EC8D0016; Sat, 7 Oct 2023 16:36:17 -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 A6FD18D0013 for ; Sat, 7 Oct 2023 16:36:17 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7E720A0297 for ; Sat, 7 Oct 2023 20:36:17 +0000 (UTC) X-FDA: 81319822794.06.85F2478 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id E2D0680004 for ; Sat, 7 Oct 2023 20:36:15 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Cr3o8RWM; spf=none (imf02.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=1696710976; 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=TkvZj289LjVT0INkRek2vP8VRKU8xKxNyMII+enlEWg=; b=g1F2nyCy460GZDX9vPYpzIzEBqrzXWiMmPxMyAXmqRnfA9huxurWFUd7ahwVZGRjrD58io 95tFXG0b4JtU7Hg9vSJtgvgkvaYAgLD5tQiOVrBayasNV3o7wrHyGdhS0SiX+nIbTo62yq 9L/03cZL7YHPLgKjl/sawUrQ7n/+Ov0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696710976; a=rsa-sha256; cv=none; b=ypFaeqs+lFsbIFzyjAtcupip5AVEnGoRzDk8IHdxIz+/1RJYElkj17Ius9M3WFl/HZhsZc nUD25UhornP/MndMlqnV14DL2D5ecoPyle1C+2SB+V+uHKVzRs0SlCEmtAfnrEeiXpWH2w zix4GyoBtXdpf3x/cx2v9Mvz6Sp50zs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Cr3o8RWM; spf=none (imf02.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: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=TkvZj289LjVT0INkRek2vP8VRKU8xKxNyMII+enlEWg=; b=Cr3o8RWM58gE0W4E+dSE8SE0UL Xdcas8AZH3bSf8486FYpIVyUco+VLPvf8wArWBxyCMYcnkQZ5EHF6gBsxnToFtBVVVJGVweSpnVXG pVd5zoHUthMI/p+Fw5DlYC8zihzCaba7WMrYWvlsg35gA9HJoxVD5QlfNdxIbV6B49ZS27saqgbkn m0pDKlI9KhEULZMOZCA2a44zVKUNvfOAi/6aiqRxOCvy+CLRBqDu5K+/CSPv/tCHzTULgIAgcedI+ 8Oc/wngAVrGkFfEWscWUjCALfTLekMn69t9FAP5LxXoUB+utuJ1/nJjrk2DNbLHtZQDB8SnVbkP0O RMOIsMmw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qpE1Y-005mLC-LZ; 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 2/5] mm: Use rwsem assertion macros for mmap_lock Date: Sat, 7 Oct 2023 21:35:40 +0100 Message-Id: <20231007203543.1377452-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231007203543.1377452-1-willy@infradead.org> References: <20231007203543.1377452-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: zkrckwj81oc4opgy3m5ybz4j43xaa1yr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E2D0680004 X-Rspam-User: X-HE-Tag: 1696710975-314758 X-HE-Meta: U2FsdGVkX18KYc68Xwy5Y9szCluDAeQ0ckp85EwEuBwInERuu+MdO1mEJkODsr4vJ7xZm9lvVTkLJhaDwFkUvppp5AxKfycwfcWk43CvBXQP1et4g3WP41AxDKMC8+zb4wjkp6Gj7SYnWUReJWD6tLUJpMIX006mIZK01aqnLmzZ1rDzCUZhqnRi1SJfGZcWAT4woiRZs496vIHOhnu59DyiovQFS5I8FhJm5mJNJ0I+Lqpz5q9SOKbBJgn22s1Znqb+3IK5dmX2q4VNPFLhNDi+o5L/rTIc/GgHXFvJv3FYY/FNbNDAQIy9cbeLQgX3hkg5Adsn6mRfo7RLKxgspbtnLYU5TKVfsoIAVknMCtvv2SWJgHftIOpZtwqkjQ3ceVEob98up6ZWIJZiZdOsvAXXzacP+aZcF+DWQtRxfVdDs4GuTx2lauqKbEcviiEUlXlTmdJp+X7sWiJzz9VYqpotZ+2Krwzi0YQmdp2j1i6bCUHHfS98aUyaeYYd9RQtc/lG8vLqDy3VNoVpml50da5l2AAeyfEKkqE7Ntb3ilBvyhnfOUTgDj3qDOklUyRA3QmShEdfcBIZ+xpSRp8hGicZL6D4n953Sjho0WiF8OyIHcKp4ALN71GAo58tALjqLBCNObrR4203UquqEQA1zN4JasDT7LhA2e1/zfKo5xV5TDTSK6bMmYmazvUPP42qAQoETZ6bhr3m+SbON2iMDbPZ1Vu5NwPj6IBeZ9H5hfGPrQFK+MVZ5fzsgcMsCFjwkRYQg8yJX9drxDsLu4ldtE640bXlPKX35I0zmiTWwuRi7563wGWUrx/UUdk3g39j9onFvrw3pxQ9MbR0N7n3adPphWa0PPRvcigV7RzWFoDRyJy4J9R4lSaTyZg0Y2dqWgFYFCY6Q9wBiNFWNCtDwnm8LyafCxwhZgz03DDWr4WRnXu2dSHV4zyjCXZedaUrEZ1nktVqkNSTlsOa6AJ 5DG7IG1R FwZqZnmRE1Z17/UgSf2uMQMesF9z/uFqj+k4W9oWemcutNaT0ywHftVmXwKEzElz5cp/OdITM7u8zVdTXr3Wo1D7aYmR0jn32iOUOi8oudTEdpEqXCY6nqxLI8vRFN/zHGHzTYMMIItMCPLHpYHkTgN/oJgrcZgWRtPJt4rsmqZwtm5yKrw6lScMhqvjY55Iu2F4Fz4Xhnw2+9OSusX92TP15g1jiUcFb/YUa 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: 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) --- 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