Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: use rwsem assertion macros for mmap_lock

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.

Link: https://lkml.kernel.org/r/20240327190701.1082560-1-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Andrew Morton
ba168b52 c0bff412

+4 -6
+4 -6
include/linux/mmap_lock.h
··· 60 60 61 61 #endif /* CONFIG_TRACING */ 62 62 63 - static inline void mmap_assert_locked(struct mm_struct *mm) 63 + static inline void mmap_assert_locked(const struct mm_struct *mm) 64 64 { 65 - lockdep_assert_held(&mm->mmap_lock); 66 - VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm); 65 + rwsem_assert_held(&mm->mmap_lock); 67 66 } 68 67 69 - static inline void mmap_assert_write_locked(struct mm_struct *mm) 68 + static inline void mmap_assert_write_locked(const struct mm_struct *mm) 70 69 { 71 - lockdep_assert_held_write(&mm->mmap_lock); 72 - VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm); 70 + rwsem_assert_held_write(&mm->mmap_lock); 73 71 } 74 72 75 73 #ifdef CONFIG_PER_VMA_LOCK