summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2019-08-26 16:14:25 -0400
committerJason Gunthorpe <jgg@mellanox.com>2019-09-07 03:28:04 -0400
commit810e24e009cf71bf85a1524f272a744c54ca6591 (patch)
tree44b8303c6a89e20067f265785a09304d3bbac65c
parent66204f1d2d1b42962033dfa867442f3dfd898d5f (diff)
mm/mmu_notifiers: annotate with might_sleep()
Since mmu notifiers don't exist for many processes, but could block in interesting places, add some annotations. This should help make sure the core mm keeps up its end of the mmu notifier contract. The checks here are outside of all notifier checks because of that. They compile away without CONFIG_DEBUG_ATOMIC_SLEEP. Link: https://lore.kernel.org/r/20190826201425.17547-6-daniel.vetter@ffwll.ch Suggested-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Reviewed-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--include/linux/mmu_notifier.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h
index 4dfe996dafd2..1bd8e6a09a3c 100644
--- a/include/linux/mmu_notifier.h
+++ b/include/linux/mmu_notifier.h
@@ -343,6 +343,8 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm,
343static inline void 343static inline void
344mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) 344mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
345{ 345{
346 might_sleep();
347
346 lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); 348 lock_map_acquire(&__mmu_notifier_invalidate_range_start_map);
347 if (mm_has_notifiers(range->mm)) { 349 if (mm_has_notifiers(range->mm)) {
348 range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE; 350 range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE;
@@ -368,6 +370,9 @@ mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range)
368static inline void 370static inline void
369mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) 371mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range)
370{ 372{
373 if (mmu_notifier_range_blockable(range))
374 might_sleep();
375
371 if (mm_has_notifiers(range->mm)) 376 if (mm_has_notifiers(range->mm))
372 __mmu_notifier_invalidate_range_end(range, false); 377 __mmu_notifier_invalidate_range_end(range, false);
373} 378}