On Thu, Aug 08, 2019 at 06:42:40PM +0300, Christoph Hellwig wrote: > Use lockdep to check for held locks instead of using home grown > asserts. > > @@ -319,7 +319,7 @@ int walk_page_range(struct mm_struct *mm, unsigned long start, > if (!walk.mm) > return -EINVAL; > > - VM_BUG_ON_MM(!rwsem_is_locked(&walk.mm->mmap_sem), walk.mm); > + lockdep_assert_held(&walk.mm->mmap_sem); It occurs to me that this is exactly the pattern that lockdep_pin_lock() was designed for. I'm pretty sure things will go badly if any callee unlocks then relocks the lock.