Re: [PATCH v4 09/10] mmap locking API: use lockdep_assert_held

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
}





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux