summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/hugetlbfs/inode.c7
-rw-r--r--include/linux/hugetlb.h4
-rw-r--r--mm/hugetlb.c22
-rw-r--r--mm/userfaultfd.c3
4 files changed, 10 insertions, 26 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c74ef4426282..f23237135163 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -440,9 +440,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
440 u32 hash; 440 u32 hash;
441 441
442 index = page->index; 442 index = page->index;
443 hash = hugetlb_fault_mutex_hash(h, current->mm, 443 hash = hugetlb_fault_mutex_hash(h, mapping, index, 0);
444 &pseudo_vma,
445 mapping, index, 0);
446 mutex_lock(&hugetlb_fault_mutex_table[hash]); 444 mutex_lock(&hugetlb_fault_mutex_table[hash]);
447 445
448 /* 446 /*
@@ -639,8 +637,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
639 addr = index * hpage_size; 637 addr = index * hpage_size;
640 638
641 /* mutex taken here, fault path and hole punch */ 639 /* mutex taken here, fault path and hole punch */
642 hash = hugetlb_fault_mutex_hash(h, mm, &pseudo_vma, mapping, 640 hash = hugetlb_fault_mutex_hash(h, mapping, index, addr);
643 index, addr);
644 mutex_lock(&hugetlb_fault_mutex_table[hash]); 641 mutex_lock(&hugetlb_fault_mutex_table[hash]);
645 642
646 /* See if already present in mapping to avoid alloc/free */ 643 /* See if already present in mapping to avoid alloc/free */
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 11943b60f208..edf476c8cfb9 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -123,9 +123,7 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason);
123void free_huge_page(struct page *page); 123void free_huge_page(struct page *page);
124void hugetlb_fix_reserve_counts(struct inode *inode); 124void hugetlb_fix_reserve_counts(struct inode *inode);
125extern struct mutex *hugetlb_fault_mutex_table; 125extern struct mutex *hugetlb_fault_mutex_table;
126u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm, 126u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
127 struct vm_area_struct *vma,
128 struct address_space *mapping,
129 pgoff_t idx, unsigned long address); 127 pgoff_t idx, unsigned long address);
130 128
131pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud); 129pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c33c5cbb67ff..98a3c7c224cb 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3824,8 +3824,7 @@ retry:
3824 * handling userfault. Reacquire after handling 3824 * handling userfault. Reacquire after handling
3825 * fault to make calling code simpler. 3825 * fault to make calling code simpler.
3826 */ 3826 */
3827 hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, 3827 hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr);
3828 idx, haddr);
3829 mutex_unlock(&hugetlb_fault_mutex_table[hash]); 3828 mutex_unlock(&hugetlb_fault_mutex_table[hash]);
3830 ret = handle_userfault(&vmf, VM_UFFD_MISSING); 3829 ret = handle_userfault(&vmf, VM_UFFD_MISSING);
3831 mutex_lock(&hugetlb_fault_mutex_table[hash]); 3830 mutex_lock(&hugetlb_fault_mutex_table[hash]);
@@ -3933,21 +3932,14 @@ backout_unlocked:
3933} 3932}
3934 3933
3935#ifdef CONFIG_SMP 3934#ifdef CONFIG_SMP
3936u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm, 3935u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
3937 struct vm_area_struct *vma,
3938 struct address_space *mapping,
3939 pgoff_t idx, unsigned long address) 3936 pgoff_t idx, unsigned long address)
3940{ 3937{
3941 unsigned long key[2]; 3938 unsigned long key[2];
3942 u32 hash; 3939 u32 hash;
3943 3940
3944 if (vma->vm_flags & VM_SHARED) { 3941 key[0] = (unsigned long) mapping;
3945 key[0] = (unsigned long) mapping; 3942 key[1] = idx;
3946 key[1] = idx;
3947 } else {
3948 key[0] = (unsigned long) mm;
3949 key[1] = address >> huge_page_shift(h);
3950 }
3951 3943
3952 hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0); 3944 hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0);
3953 3945
@@ -3958,9 +3950,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm,
3958 * For uniprocesor systems we always use a single mutex, so just 3950 * For uniprocesor systems we always use a single mutex, so just
3959 * return 0 and avoid the hashing overhead. 3951 * return 0 and avoid the hashing overhead.
3960 */ 3952 */
3961u32 hugetlb_fault_mutex_hash(struct hstate *h, struct mm_struct *mm, 3953u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping,
3962 struct vm_area_struct *vma,
3963 struct address_space *mapping,
3964 pgoff_t idx, unsigned long address) 3954 pgoff_t idx, unsigned long address)
3965{ 3955{
3966 return 0; 3956 return 0;
@@ -4005,7 +3995,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
4005 * get spurious allocation failures if two CPUs race to instantiate 3995 * get spurious allocation failures if two CPUs race to instantiate
4006 * the same page in the page cache. 3996 * the same page in the page cache.
4007 */ 3997 */
4008 hash = hugetlb_fault_mutex_hash(h, mm, vma, mapping, idx, haddr); 3998 hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr);
4009 mutex_lock(&hugetlb_fault_mutex_table[hash]); 3999 mutex_lock(&hugetlb_fault_mutex_table[hash]);
4010 4000
4011 entry = huge_ptep_get(ptep); 4001 entry = huge_ptep_get(ptep);
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index d59b5a73dfb3..9932d5755e4c 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -271,8 +271,7 @@ retry:
271 */ 271 */
272 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; 273 mapping = dst_vma->vm_file->f_mapping;
274 hash = hugetlb_fault_mutex_hash(h, dst_mm, dst_vma, mapping, 274 hash = hugetlb_fault_mutex_hash(h, mapping, idx, dst_addr);
275 idx, dst_addr);
276 mutex_lock(&hugetlb_fault_mutex_table[hash]); 275 mutex_lock(&hugetlb_fault_mutex_table[hash]);
277 276
278 err = -ENOMEM; 277 err = -ENOMEM;