On Tue, Apr 21, 2020 at 07:18:50PM -0700, Matthew Wilcox wrote: > On Tue, Apr 21, 2020 at 07:10:39PM -0700, Michel Lespinasse wrote: > > On Tue, Apr 21, 2020 at 5:14 PM Michel Lespinasse <walken@xxxxxxxxxx> wrote: > > > +static inline void mmap_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); > > > +} > > > > Turns out this function definition does not work for !CONFIG_LOCKDEP > > as lockdep_is_held is not defined in that case. > > Oops, sorry. It only defines > > #define lockdep_is_held_type(l, r) (1) > #define lockdep_assert_held(l) do { (void)(l); } while (0) > #define lockdep_assert_held_write(l) do { (void)(l); } while (0) > #define lockdep_assert_held_read(l) do { (void)(l); } while (0) > #define lockdep_assert_held_once(l) do { (void)(l); } while (0) > > which seems like an oversight, but not one that you should be fixing. > > > The following should work instead: > > > > static inline void mmap_assert_locked(struct mm_struct *mm) > > { > > #ifdef CONFIG_LOCKDEP > > if (debug_locks) { > > VM_BUG_ON_MM(!lockdep_is_held(&mm->mmap_lock), mm); > > return; > > } > > #endif > > VM_BUG_ON_MM(!rwsem_is_locked(&mm->mmap_lock), mm); > > } > > Yes, I agree. Sent an updated version of this (also integrating your feedback on patch 10/10) Please look for it under subject: [PATCH v5.5 09/10] mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked() -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.