Re: [PATCH] mm: gup: fix the fast GUP race against THP collapse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/6/22 11:50, Yang Shi wrote:
>>> -             if (unlikely(pte_val(pte) != pte_val(*ptep))) {
>>> +             /*
>>> +              * THP collapse conceptually does:
>>> +              *   1. Clear and flush PMD
>>> +              *   2. Check the base page refcount
>>> +              *   3. Copy data to huge page
>>> +              *   4. Clear PTE
>>> +              *   5. Discard the base page
>>> +              *
>>> +              * So fast GUP may race with THP collapse then pin and
>>> +              * return an old page since TLB flush is no longer sufficient
>>> +              * to serialize against fast GUP.
>>> +              *
>>> +              * Check PMD, if it is changed just back off since it
>>> +              * means there may be parallel THP collapse.
>>> +              */
>>
>> As I mentioned in the other thread, it would be a nice touch to move
>> such discussion into the comment header.
> 
> Sure, you mean the comment before gup_pte_range() so that the real
> code stays succinct, right?
Yes.

thanks,

-- 
John Hubbard
NVIDIA





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux