[PATCH 2/5] mm, notifier: Prime lockdep

Daniel Vetter daniel.vetter at ffwll.ch
Mon Aug 26 20:14:22 UTC 2019

We want to teach lockdep that mmu notifiers can be called from direct
reclaim paths, since on many CI systems load might never reach that
level (e.g. when just running fuzzer or small functional tests).

Motivated by a discussion with Jason.

I've put the annotation into mmu_notifier_register since only when we
have mmu notifiers registered is there any point in teaching lockdep
about them. Also, we already have a kmalloc(, GFP_KERNEL), so this is

Cc: Jason Gunthorpe <jgg at ziepe.ca>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: David Rientjes <rientjes at google.com>
Cc: "Jérôme Glisse" <jglisse at redhat.com>
Cc: Michal Hocko <mhocko at suse.com>
Cc: "Christian König" <christian.koenig at amd.com>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Mike Rapoport <rppt at linux.vnet.ibm.com>
Cc: linux-mm at kvack.org
Reviewed-by: Jason Gunthorpe <jgg at mellanox.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
 mm/mmu_notifier.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
index d48d3b2abd68..0523555933c9 100644
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -259,6 +259,13 @@ int __mmu_notifier_register(struct mmu_notifier *mn, struct mm_struct *mm)
 	BUG_ON(atomic_read(&mm->mm_users) <= 0);
+		fs_reclaim_acquire(GFP_KERNEL);
+		lock_map_acquire(&__mmu_notifier_invalidate_range_start_map);
+		lock_map_release(&__mmu_notifier_invalidate_range_start_map);
+		fs_reclaim_release(GFP_KERNEL);
+	}
 	mn->mm = mm;
 	mn->users = 1;

More information about the dri-devel mailing list