The caller needs to make sure that the vma is not torn down during the lock operation and can also use the i_mmap_rwsem for file-backed vmas. Remove the BUG_ON. We could, as an alternative, add a test that either vma->vm_mm->mmap_sem or vma->vm_file->f_mapping->i_mmap_rwsem are held.
Showing the changes to include/linux (1 of 1 file). Show all
Unified · Split
| @@ -216,7 +216,6 @@ static inline int is_swap_pmd(pmd_t pmd) · 215 unmodified lines | |||
| 216 | static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, | 216 | static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, |
| 217 | struct vm_area_struct *vma) | 217 | struct vm_area_struct *vma) |
| 218 | { | 218 | { |
| 219 | VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma); | ||
| 220 | if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) | 219 | if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) |
| 221 | return __pmd_trans_huge_lock(pmd, vma); | 220 | return __pmd_trans_huge_lock(pmd, vma); |
| 222 | else | 221 | else |
| @@ -225,7 +224,6 @@ static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, · 2 unmodified lines | |||
| 225 | static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, | 224 | static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, |
| 226 | struct vm_area_struct *vma) | 225 | struct vm_area_struct *vma) |
| 227 | { | 226 | { |
| 228 | VM_BUG_ON_VMA(!rwsem_is_locked(&vma->vm_mm->mmap_sem), vma); | ||
| 229 | if (pud_trans_huge(*pud) || pud_devmap(*pud)) | 227 | if (pud_trans_huge(*pud) || pud_devmap(*pud)) |
| 230 | return __pud_trans_huge_lock(pud, vma); | 228 | return __pud_trans_huge_lock(pud, vma); |
| 231 | else | 229 | else |