The patch titled Subject: hugetlb: detect race upon page allocation failure during COW has been added to the -mm tree. Its filename is hugetlb-detect-race-upon-page-allocation-failure-during-cow.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ From: Hillf Danton <dhillf@xxxxxxxxx> Subject: hugetlb: detect race upon page allocation failure during COW In the error path where we failed to allocate a new huge page, we should check whether a racing thread has added this page for us while this thread waited for the page_table_lock. We are serialized by hugetlb_instantiation_mutex on the pagefault patch but this race can occur when another thread is performing page migration. Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx> Reviewed-by: Michal Hocko <mhocko@xxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: Johannes Weiner <jweiner@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/hugetlb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff -puN mm/hugetlb.c~hugetlb-detect-race-upon-page-allocation-failure-during-cow mm/hugetlb.c --- a/mm/hugetlb.c~hugetlb-detect-race-upon-page-allocation-failure-during-cow +++ a/mm/hugetlb.c @@ -2407,7 +2407,14 @@ retry_avoidcopy: BUG_ON(page_count(old_page) != 1); BUG_ON(huge_pte_none(pte)); spin_lock(&mm->page_table_lock); - goto retry_avoidcopy; + ptep = huge_pte_offset(mm, address & huge_page_mask(h)); + if (likely(pte_same(huge_ptep_get(ptep), pte))) + goto retry_avoidcopy; + /* + * race occurs while re-acquiring page_table_lock, and + * our job is done. + */ + return 0; } WARN_ON_ONCE(1); } _ Subject: Subject: hugetlb: detect race upon page allocation failure during COW Patches currently in -mm which might be from dhillf@xxxxxxxxx are origin.patch linux-next.patch hugetlb-detect-race-upon-page-allocation-failure-during-cow.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html