mmap locking API: add mmap_assert_locked() and mmap_assert_write_locked()
Add new APIs to assert that mmap_sem is held. Using this instead of rwsem_is_locked and lockdep_assert_held[_write] makes the assertions more tolerant of future changes to the lock type. Signed-off-by: Michel Lespinasse <walken@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com> Cc: Davidlohr Bueso <dbueso@suse.de> Cc: David Rientjes <rientjes@google.com> Cc: Hugh Dickins <hughd@google.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Jerome Glisse <jglisse@redhat.com> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Laurent Dufour <ldufour@linux.ibm.com> Cc: Liam Howlett <Liam.Howlett@oracle.com> Cc: Matthew Wilcox <willy@infradead.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ying Han <yinghan@google.com> Link: http://lkml.kernel.org/r/20200520052908.204642-10-walken@google.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cette révision appartient à :

révisé par
Linus Torvalds

Parent
14c3656b72
révision
42fc541404
@@ -609,7 +609,7 @@ int __mmu_notifier_register(struct mmu_notifier *subscription,
|
||||
struct mmu_notifier_subscriptions *subscriptions = NULL;
|
||||
int ret;
|
||||
|
||||
lockdep_assert_held_write(&mm->mmap_sem);
|
||||
mmap_assert_write_locked(mm);
|
||||
BUG_ON(atomic_read(&mm->mm_users) <= 0);
|
||||
|
||||
if (IS_ENABLED(CONFIG_LOCKDEP)) {
|
||||
@@ -761,7 +761,7 @@ struct mmu_notifier *mmu_notifier_get_locked(const struct mmu_notifier_ops *ops,
|
||||
struct mmu_notifier *subscription;
|
||||
int ret;
|
||||
|
||||
lockdep_assert_held_write(&mm->mmap_sem);
|
||||
mmap_assert_write_locked(mm);
|
||||
|
||||
if (mm->notifier_subscriptions) {
|
||||
subscription = find_get_mmu_notifier(mm, ops);
|
||||
@@ -1006,7 +1006,7 @@ int mmu_interval_notifier_insert_locked(
|
||||
mm->notifier_subscriptions;
|
||||
int ret;
|
||||
|
||||
lockdep_assert_held_write(&mm->mmap_sem);
|
||||
mmap_assert_write_locked(mm);
|
||||
|
||||
if (!subscriptions || !subscriptions->has_itree) {
|
||||
ret = __mmu_notifier_register(NULL, mm);
|
||||
|
Référencer dans un nouveau ticket
Bloquer un utilisateur