aboutsummaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r--mm/hugetlb.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ede7e7f5d1ab..6d7296dd11b8 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3856,6 +3856,25 @@ retry:
3856 3856
3857 page = alloc_huge_page(vma, haddr, 0); 3857 page = alloc_huge_page(vma, haddr, 0);
3858 if (IS_ERR(page)) { 3858 if (IS_ERR(page)) {
3859 /*
3860 * Returning error will result in faulting task being
3861 * sent SIGBUS. The hugetlb fault mutex prevents two
3862 * tasks from racing to fault in the same page which
3863 * could result in false unable to allocate errors.
3864 * Page migration does not take the fault mutex, but
3865 * does a clear then write of pte's under page table
3866 * lock. Page fault code could race with migration,
3867 * notice the clear pte and try to allocate a page
3868 * here. Before returning error, get ptl and make
3869 * sure there really is no pte entry.
3870 */
3871 ptl = huge_pte_lock(h, mm, ptep);
3872 if (!huge_pte_none(huge_ptep_get(ptep))) {
3873 ret = 0;
3874 spin_unlock(ptl);
3875 goto out;
3876 }
3877 spin_unlock(ptl);
3859 ret = vmf_error(PTR_ERR(page)); 3878 ret = vmf_error(PTR_ERR(page));
3860 goto out; 3879 goto out;
3861 } 3880 }