lkml.org 
[lkml]   [2020]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 09/10] mmap locking API: add mmap_assert_locked
On Tue, Apr 21, 2020 at 5:14 PM Michel Lespinasse <walken@google.com> 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.

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

\
 
 \ /
  Last update: 2020-04-22 04:11    [W:0.163 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site