lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14C73423-C643-4B72-B3DD-573F5636B5E0@nvidia.com>
Date:   Fri, 11 Aug 2023 12:11:55 -0400
From:   Zi Yan <ziy@...dia.com>
To:     David Hildenbrand <david@...hat.com>
Cc:     Peter Xu <peterx@...hat.com>, Matthew Wilcox <willy@...radead.org>,
        Ryan Roberts <ryan.roberts@....com>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        linux-doc@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jonathan Corbet <corbet@....net>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Hugh Dickins <hughd@...gle.com>,
        Yin Fengwei <fengwei.yin@...el.com>,
        Yang Shi <shy828301@...il.com>
Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios

On 11 Aug 2023, at 12:08, David Hildenbrand wrote:

> On 11.08.23 17:58, Peter Xu wrote:
>> On Fri, Aug 11, 2023 at 05:32:37PM +0200, David Hildenbrand wrote:
>>> On 11.08.23 17:18, Peter Xu wrote:
>>>> On Fri, Aug 11, 2023 at 12:27:13AM +0200, David Hildenbrand wrote:
>>>>> On 10.08.23 23:48, Matthew Wilcox wrote:
>>>>>> On Thu, Aug 10, 2023 at 04:57:11PM -0400, Peter Xu wrote:
>>>>>>> AFAICS if that patch was all correct (while I'm not yet sure..), you can
>>>>>>> actually fit your new total mapcount field into page 1 so even avoid the
>>>>>>> extra cacheline access.  You can have a look: the trick is refcount for
>>>>>>> tail page 1 is still seems to be free on 32 bits (if that was your worry
>>>>>>> before).  Then it'll be very nice if to keep Hugh's counter all in tail 1.
>>>>>>
>>>>>> No, refcount must be 0 on all tail pages.  We rely on this in many places
>>>>>> in the MM.
>>>>>
>>>>> Very right.
>>>>
>>>> Obviously I could have missed this in the past.. can I ask for an example
>>>> explaining why refcount will be referenced before knowing it's a head?
>>>
>>> I think the issue is, when coming from a PFN walker (or GUP-fast), you might
>>> see "oh, this is a folio, let's lookup the head page". And you do that.
>>>
>>> Then, you try taking a reference on that head page. (see try_get_folio()).
>>>
>>> But as you didn't hold a reference on the folio yet, it can happily get
>>> freed + repurposed in the meantime, so maybe it's not a head page anymore.
>>>
>>> So if the field would get reused for something else, grabbing a reference
>>> would corrupt whatever is now stored in there.
>>
>> Not an issue before large folios, am I right?  Because having a head page
>> reused as tail cannot happen iiuc with current thps if only pmd-sized,
>> because the head page is guaranteed to be pmd aligned physically.
>
> There are other users of compound pages, no? THP and hugetlb are just two examples I think. For example, I can spot __GFP_COMP in slab code.
>
> Must such compound pages would not be applicable to GUP, though, but to PFN walkers could end up trying to grab them.
>
For FS supporting large folios, their page cache pages can be any order <= PMD_ORDER.
See page_cache_ra_order() in mm/readahead.c

>>
>> I don't really know, where a hugetlb 2M head can be reused by a 1G huge
>> later right during the window of fast-gup walking. But obviously that's not
>> common either if that could ever happen.
>>
>> Maybe Matthew was referring to something else (per "in many places")?
>
> There are some other cases where PFN walkers want to identify tail pages to skip over them. See the comment in has_unmovable_pages().
>
> -- 
> Cheers,
>
> David / dhildenb


--
Best Regards,
Yan, Zi

Download attachment "signature.asc" of type "application/pgp-signature" (855 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ