Skip to content

Commit 810e24e

Browse files
danvetjgunthorpe
authored andcommitted
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>
1 parent 66204f1 commit 810e24e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎include/linux/mmu_notifier.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm,
343343
static inline void
344344
mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
345345
{
346+
might_sleep();
347+
346348
lock_map_acquire(&__mmu_notifier_invalidate_range_start_map);
347349
if (mm_has_notifiers(range->mm)) {
348350
range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE;
@@ -368,6 +370,9 @@ mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range)
368370
static inline void
369371
mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range)
370372
{
373+
if (mmu_notifier_range_blockable(range))
374+
might_sleep();
375+
371376
if (mm_has_notifiers(range->mm))
372377
__mmu_notifier_invalidate_range_end(range, false);
373378
}

0 commit comments

Comments
 (0)