diff options
| author | Mark Brown <broonie@kernel.org> | 2021-01-13 17:56:59 +0000 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2021-01-13 17:56:59 +0000 |
| commit | 2d446c98cde3ffccfd14849b7dda4194ab62dd20 (patch) | |
| tree | 9b7f048dcddec04d94527132834fc056745fdb6d /mm/hugetlb.c | |
| parent | 44a4cfad8d78efcda9ec0dd97ceea38d8b602f24 (diff) | |
| parent | 7c53f6b671f4aba70ff15e1b05148b10d58c2837 (diff) | |
Merge v5.11-rc3
Diffstat (limited to 'mm/hugetlb.c')
| -rw-r--r-- | mm/hugetlb.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index cbf32d2824fd..a2602969873d 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4105,10 +4105,30 @@ retry_avoidcopy: * may get SIGKILLed if it later faults. */ if (outside_reserve) { + struct address_space *mapping = vma->vm_file->f_mapping; + pgoff_t idx; + u32 hash; + put_page(old_page); BUG_ON(huge_pte_none(pte)); + /* + * Drop hugetlb_fault_mutex and i_mmap_rwsem before + * unmapping. unmapping needs to hold i_mmap_rwsem + * in write mode. Dropping i_mmap_rwsem in read mode + * here is OK as COW mappings do not interact with + * PMD sharing. + * + * Reacquire both after unmap operation. + */ + idx = vma_hugecache_offset(h, vma, haddr); + hash = hugetlb_fault_mutex_hash(mapping, idx); + mutex_unlock(&hugetlb_fault_mutex_table[hash]); + i_mmap_unlock_read(mapping); + unmap_ref_private(mm, vma, old_page, haddr); - BUG_ON(huge_pte_none(pte)); + + i_mmap_lock_read(mapping); + mutex_lock(&hugetlb_fault_mutex_table[hash]); spin_lock(ptl); ptep = huge_pte_offset(mm, haddr, huge_page_size(h)); if (likely(ptep && |
