From patchwork Fri Nov 17 14:51: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: 13459015 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 CFB6DC5AD4C for ; Fri, 17 Nov 2023 14:52:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61BDB6B04DB; Fri, 17 Nov 2023 09:52:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F1E36B04E1; Fri, 17 Nov 2023 09:52:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A6526B04DF; Fri, 17 Nov 2023 09:52:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E67136B04DB for ; Fri, 17 Nov 2023 09:52:04 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C36611A05D3 for ; Fri, 17 Nov 2023 14:52:04 +0000 (UTC) X-FDA: 81467736168.22.73608B5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id 26222140029 for ; Fri, 17 Nov 2023 14:52:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=G81dPiQI; dmarc=none; spf=none (imf26.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=1700232723; 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=25QfWharHbMWrIl6caRn0CZ+MZ75oP4Z9qoseEg2zjc=; b=kN7pUhm1dA7NAyOQDTxQKPOpbLC5B5hqZPZZw9ju68VeK/J812eKMhEavzn5cw41p3hIR4 J0iyVkgFJQmc3jFJYcqQeIPJexvn0kJ/TJaIZTuEBhookzAm2/uTgoGRnFRZqtmMZDUtCG YW4+mMF8QjSawJqCGH3mVASQXuVHym4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=G81dPiQI; dmarc=none; spf=none (imf26.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=1700232723; a=rsa-sha256; cv=none; b=EkE6qzQ/MbsC7HzECP5CgOSDXXPnBSG4W0Dk1hd7TvLl7y5v7B9uSL1ATQ3ZpWbVJMm0qK B3LF5X5R3TJfJP6P/dUmYvhB5Rex4R5OdvvL5uCNfH5EIwOcW4g73iaEKUntX7CHzg7DGB zcvxFONS8UGlxKkx8a6TS4x78vhU11g= 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=25QfWharHbMWrIl6caRn0CZ+MZ75oP4Z9qoseEg2zjc=; b=G81dPiQIHl0SfOKIPMZ8I9sw2V d5ARoUWM1/yrnIdvjjTz4FsVu4uYDcbTLzSzH9bRwHDPxLfwbH/ILpx4RNS/G5aRerWYAFKNQa0oV +3SrFGRIhq2VzyXgwrmZZKHOs50oadM/vEMDA5KZRzEySyyeS9Pt0/H+jP3ODZaK5NZnH/XcIZC+U HWiWKF4SQx8ge+N3F+EDUFb9KgYvH/Z4E0pVcv0QrGrimiNp98ZrAKM+28ysPuxS7mlOvyv+eIcMj kmgYY9P65vTsHGeZz3gSLjNBxHZcWLLJ3eRMZMCL+gfHEXD4THepQSNv0oPCJaAG0deVfJWPq+i2d QnOeX+/g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r40C7-009ypz-Ry; 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 2/4] mm: Use rwsem assertion macros for mmap_lock Date: Fri, 17 Nov 2023 14:51:40 +0000 Message-Id: <20231117145142.2378800-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117145142.2378800-1-willy@infradead.org> References: <20231117145142.2378800-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 26222140029 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pas4zpzsacr9j8xy5534tnu7j34j85n3 X-HE-Tag: 1700232722-980520 X-HE-Meta: U2FsdGVkX1/fNK0tutAAMtK1/GNiGU4ZcGfuMhS3kjisjptpR5G9iSi27H1pWLACzYLQJ1kuqikTc2TFKeAZGB0DzmhNXb5zmawa0X2f1H4XXg8H4HKh18bx4YolyjVfFO4vMEKbp3gPnhquuMNpJ7x/wgQCmVgY82R95g8imktETJgqfx6IA5/Fqz1EQlAdwlmXkU3H28Wy2jcz5oGC03CZ0QE8GJlqFVRVwBNB2qXw5pd7V6AmrKvoo3e9y9UsngcBkIYpl0JBX82F+87fC6d1Lwd7Bylp2ASnBdlkE4jyssuF69X8dRkRgmIKY+3nG3EkEQyTos5CNYONITQFNShpnJk0eJ2HyWDQPz7yt+SCKbKrOCvuohd3sZVZQmNTBJE2hsh77zWi5vKFll4uVh21zNOpXmi58Bi1RC56Al+QCNcL84xjZcq9F48SGIXhh71NqbChQbnMj7YKR5eJDUOILJu8/J0JrnOr4CZFSpbRDGoAjqVqUp7e5lp6vFSyUKX7TZz61MbkQJzJyDsiFxN4nAnr+kd2WPeKRbL1KWB216xloYic4w7u9mPpue8ANDJtztKQVt1IfQXt90Ckh/XDRaBWDuXdnIO/9jVH3gzkpjPNfYSxfbTJs6cgd/MGWqYMW6pCfVCqWho6XnFo685DtPr5fAzJ69WHd11ajeyjRUOfk5cxL52IKNT0evInGMlnNDX9CMZ1ZX5wPRqX2Cm1hl5nkmjxIpl8jboa9oAYsn3zOH8hjD6FfEoy/TucHN0EMJOcVZgEgittt8Awht/E7gkWZn4gxyn6E+l7QOfrToaJJm2SM6mcpuonKGTdcyYbuPIjs0DAy/qT3r6p+uSo+97W+R5AVqEsP9FdKkS+Xu4RvZowho5xvmv4xNbPs4D2yoHQknLEa0jOnWKmeuGovOlXTFl4CNsU3syOInJG428jbwPf2p+tWWJE9Gfz9gd7enqRiHnu1txpqCV o7ePm2H0 jQOM8JnMEkOUnAf6uoq1WNEedlBmeZ/SEQ6REcCp4ICMywiAgHPNyGNCRxuVZb7XB7SzcviLLkx2UaDE5INq27oIbPFZyVDFSxkM4MhJXcFA/Isjclmq17IM+99Tk+uKB/Hj3PV/tBkQyACW6OMngIUN0jMA9ldlOMsX7it0ZOMHNJzt8+c5qM+iQRF+C1Hf5kWNGmXQZy4UQfQ7WCS9UNxdisWn7prktZ5Nk 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) --- 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