Re: [PATCH] hugetlbfs: fix hugetlb page migration/fault race causing SIGBUS
From: Mike Kravetz
Date: Wed Aug 07 2019 - 22:47:36 EST
On 8/7/19 7:24 PM, èçç(çç) wrote:
> Hi Mike,
>
> Do you mean the similar race is like the following?
>
> migration clearing the pte
> page fault(before we return error, and now we return 0, then try page fault again, right?)
> migration writing a migration entry
Yes, something like the that. The change is to takes the page table lock
to examine the pte before returning. If the pte is clear when examined
while holding the lock, an error will be returned as before. If not clear,
then we return zero and try again.
This change adds code which is very much like this check further in
the routine hugetlb_no_page():
ptl = huge_pte_lock(h, mm, ptep);
size = i_size_read(mapping->host) >> huge_page_shift(h);
if (idx >= size)
goto backout;
ret = 0;
if (!huge_pte_none(huge_ptep_get(ptep)))
goto backout;
--
Mike Kravetz