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.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -343,6 +343,8 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm, · 342 unmodified lines | ||
| 343 | 343 | static inline void |
| 344 | 344 | mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) |
| 345 | 345 | { |
| 346 | + might_sleep(); | |
| 347 | + | |
| 346 | 348 | lock_map_acquire(&__mmu_notifier_invalidate_range_start_map); |
| 347 | 349 | if (mm_has_notifiers(range->mm)) { |
| 348 | 350 | range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE; |
| @@ -368,6 +370,9 @@ mmu_notifier_invalidate_range_start_nonblock(struct mmu_notifier_range *range) · 19 unmodified lines | ||
| 368 | 370 | static inline void |
| 369 | 371 | mmu_notifier_invalidate_range_end(struct mmu_notifier_range *range) |
| 370 | 372 | { |
| 373 | + if (mmu_notifier_range_blockable(range)) | |
| 374 | + might_sleep(); | |
| 375 | + | |
| 371 | 376 | if (mm_has_notifiers(range->mm)) |
| 372 | 377 | __mmu_notifier_invalidate_range_end(range, false); |
| 373 | 378 | } |