diff options
Diffstat (limited to 'mm/userfaultfd.c')
-rw-r--r-- | mm/userfaultfd.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 065c1ce191c4..d59b5a73dfb3 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c | |||
@@ -267,14 +267,10 @@ retry: | |||
267 | VM_BUG_ON(dst_addr & ~huge_page_mask(h)); | 267 | VM_BUG_ON(dst_addr & ~huge_page_mask(h)); |
268 | 268 | ||
269 | /* | 269 | /* |
270 | * Serialize via i_mmap_rwsem and hugetlb_fault_mutex. | 270 | * Serialize via hugetlb_fault_mutex |
271 | * i_mmap_rwsem ensures the dst_pte remains valid even | ||
272 | * in the case of shared pmds. fault mutex prevents | ||
273 | * races with other faulting threads. | ||
274 | */ | 271 | */ |
275 | mapping = dst_vma->vm_file->f_mapping; | ||
276 | i_mmap_lock_read(mapping); | ||
277 | idx = linear_page_index(dst_vma, dst_addr); | 272 | idx = linear_page_index(dst_vma, dst_addr); |
273 | mapping = dst_vma->vm_file->f_mapping; | ||
278 | hash = hugetlb_fault_mutex_hash(h, dst_mm, dst_vma, mapping, | 274 | hash = hugetlb_fault_mutex_hash(h, dst_mm, dst_vma, mapping, |
279 | idx, dst_addr); | 275 | idx, dst_addr); |
280 | mutex_lock(&hugetlb_fault_mutex_table[hash]); | 276 | mutex_lock(&hugetlb_fault_mutex_table[hash]); |
@@ -283,7 +279,6 @@ retry: | |||
283 | dst_pte = huge_pte_alloc(dst_mm, dst_addr, huge_page_size(h)); | 279 | dst_pte = huge_pte_alloc(dst_mm, dst_addr, huge_page_size(h)); |
284 | if (!dst_pte) { | 280 | if (!dst_pte) { |
285 | mutex_unlock(&hugetlb_fault_mutex_table[hash]); | 281 | mutex_unlock(&hugetlb_fault_mutex_table[hash]); |
286 | i_mmap_unlock_read(mapping); | ||
287 | goto out_unlock; | 282 | goto out_unlock; |
288 | } | 283 | } |
289 | 284 | ||
@@ -291,7 +286,6 @@ retry: | |||
291 | dst_pteval = huge_ptep_get(dst_pte); | 286 | dst_pteval = huge_ptep_get(dst_pte); |
292 | if (!huge_pte_none(dst_pteval)) { | 287 | if (!huge_pte_none(dst_pteval)) { |
293 | mutex_unlock(&hugetlb_fault_mutex_table[hash]); | 288 | mutex_unlock(&hugetlb_fault_mutex_table[hash]); |
294 | i_mmap_unlock_read(mapping); | ||
295 | goto out_unlock; | 289 | goto out_unlock; |
296 | } | 290 | } |
297 | 291 | ||
@@ -299,7 +293,6 @@ retry: | |||
299 | dst_addr, src_addr, &page); | 293 | dst_addr, src_addr, &page); |
300 | 294 | ||
301 | mutex_unlock(&hugetlb_fault_mutex_table[hash]); | 295 | mutex_unlock(&hugetlb_fault_mutex_table[hash]); |
302 | i_mmap_unlock_read(mapping); | ||
303 | vm_alloc_shared = vm_shared; | 296 | vm_alloc_shared = vm_shared; |
304 | 297 | ||
305 | cond_resched(); | 298 | cond_resched(); |