lkml.org 
[lkml]   [2022]   [Sep]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH] mm: gup: fix the fast GUP race against THP collapse
    From
    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

    \
     
     \ /
      Last update: 2022-09-06 23:29    [W:4.572 / U:0.184 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site