lkml.org 
[lkml]   [2024]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v1 05/18] mm: improve folio_likely_mapped_shared() using the mapcount of large folios
From
On 19.04.24 04:29, Yin, Fengwei wrote:
>
>
> On 4/10/2024 3:22 AM, David Hildenbrand wrote:
>> @@ -2200,7 +2200,22 @@ static inline size_t folio_size(struct folio *folio)
>> */
>> static inline bool folio_likely_mapped_shared(struct folio *folio)
>> {
>> - return page_mapcount(folio_page(folio, 0)) > 1;
>> + int mapcount = folio_mapcount(folio);
>> +
>> + /* Only partially-mappable folios require more care. */
>> + if (!folio_test_large(folio) || unlikely(folio_test_hugetlb(folio)))
>> + return mapcount > 1;
> My understanding is that mapcount > folio_nr_pages(folio) can cover
> order 0 folio. And also folio_entire_mapcount() can cover hugetlb (I am
> not 100% sure for this one). I am wondering whether we can drop above
> two lines? Thanks.

folio_entire_mapcount() does not apply to small folios, so we must not
call that for small folios.

Regarding hugetlb, subpage mapcounts are completely unused, except
subpage 0 mapcount, which is now *always* negative (storing a page type)
-- so there is no trusting on that value at all.

So in the end, it all looked cleanest when only special-casing on
partially-mappable folios where we know the entire mapcount exists and
we know that subapge mapcount 0 actually stores something reasonable
(not a type).

Thanks!

--
Cheers,

David / dhildenb


\
 
 \ /
  Last update: 2024-05-27 16:46    [W:0.098 / U:2.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site