[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200421023542.GJ5820@bombadil.infradead.org>
Date: Mon, 20 Apr 2020 19:35:42 -0700
From: Matthew Wilcox <willy@...radead.org>
To: Michel Lespinasse <walken@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-mm <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Laurent Dufour <ldufour@...ux.ibm.com>,
Vlastimil Babka <vbabka@...e.cz>,
Liam Howlett <Liam.Howlett@...cle.com>,
Jerome Glisse <jglisse@...hat.com>,
Davidlohr Bueso <dave@...olabs.net>,
David Rientjes <rientjes@...gle.com>,
Hugh Dickins <hughd@...gle.com>, Ying Han <yinghan@...gle.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Daniel Jordan <daniel.m.jordan@...cle.com>
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);
}
Powered by blists - more mailing lists