lkml.org 
[lkml]   [2020]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 09/10] mmap locking API: use lockdep_assert_held
On Tue, Apr 14, 2020 at 05:43:52PM -0700, Michel Lespinasse wrote:
> Use lockdep_assert_held when asserting that mmap_sem is held.
>
> Using this instead of rwsem_is_locked makes the assertions more
> tolerant of future changes to the lock type.

Somebody pointed out on an earlier iteration of this patch set that
rwsem_is_locked() is enabled on all rwsems whereas lockdep_assert_held()
is only enabled when lockdep is enabled, which is not production setups.

How about this?

static inline void mm_assert_locked(struct mm_struct *mm)
{
if (IS_ENABLED(CONFIG_LOCKDEP) && debug_locks)
VM_BUG_ON_MM(!lockdep_is_held(&mm->mmap_sem), mm);
else
VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_sem), mm);
}

\
 
 \ /
  Last update: 2020-04-21 04:37    [W:0.120 / U:1.896 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site