Messages in this thread | | | Date | Mon, 20 Apr 2020 19:35:42 -0700 | From | Matthew Wilcox <> | Subject | Re: [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); }
| |