[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8e0c26c5-58d3-766e-1ddb-00c0c7af19d0@nvidia.com>
Date: Tue, 6 Sep 2022 14:27:48 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Yang Shi <shy828301@...il.com>
Cc: david@...hat.com, peterx@...hat.com,
kirill.shutemov@...ux.intel.com, jgg@...dia.com, hughd@...gle.com,
akpm@...ux-foundation.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: gup: fix the fast GUP race against THP collapse
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
Powered by blists - more mailing lists