diff mbox series

mm: Use rwsem assertion macros for mmap_lock

Message ID 20240327190701.1082560-1-willy@infradead.org (mailing list archive)
State New
Headers show
Series mm: Use rwsem assertion macros for mmap_lock | expand

Commit Message

Matthew Wilcox March 27, 2024, 7:06 p.m. UTC
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) <willy@infradead.org>
---
 include/linux/mmap_lock.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

David Hildenbrand April 2, 2024, 1:41 p.m. UTC | #1
On 27.03.24 20:06, Matthew Wilcox (Oracle) wrote:
> 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) <willy@infradead.org>
> ---
>   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

Reviewed-by: David Hildenbrand <david@redhat.com>
diff mbox series

Patch

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