From: Michal Hocko Date: Tue, 2 Aug 2016 21:02:34 +0000 (-0700) Subject: mm, hugetlb: fix huge_pte_alloc BUG_ON X-Git-Tag: v4.1.12-92~78^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=df6a779db3db5fa7e46d74c74eaa0889b21cc439;p=users%2Fjedix%2Flinux-maple.git mm, hugetlb: fix huge_pte_alloc BUG_ON Zhong Jiang has reported a BUG_ON from huge_pte_alloc hitting when he runs his database load with memory online and offline running in parallel. The reason is that huge_pmd_share might detect a shared pmd which is currently migrated and so it has migration pte which is !pte_huge. There doesn't seem to be any easy way to prevent from the race and in fact seeing the migration swap entry is not harmful. Both callers of huge_pte_alloc are prepared to handle them. copy_hugetlb_page_range will copy the swap entry and make it COW if needed. hugetlb_fault will back off and so the page fault is retries if the page is still under migration and waits for its completion in hugetlb_fault. That means that the BUG_ON is wrong and we should update it. Let's simply check that all present ptes are pte_huge instead. Link: http://lkml.kernel.org/r/20160721074340.GA26398@dhcp22.suse.cz Signed-off-by: Michal Hocko Reported-by: zhongjiang Acked-by: Naoya Horiguchi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Orabug: 24691289 (cherry picked from commit 4e666314d286765a9e61818b488c7372326654ec) Acked-by: Chuck Anderson --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f468dc3d05a3..44a6ab9aeb49 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4182,7 +4182,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, pte = (pte_t *)pmd_alloc(mm, pud, addr); } } - BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); + BUG_ON(pte && pte_present(*pte) && !pte_huge(*pte)); return pte; }