Re: [PATCH 8/9] mm/rmap: introduce folio_try_share_anon_rmap_ptes

From: Wei Yang

Date: Thu Mar 12 2026 - 04:19:23 EST


On Wed, Mar 11, 2026 at 01:39:25PM +0530, Dev Jain wrote:
>
[...]
>>> diff --git a/include/linux/rmap.h b/include/linux/rmap.h
>>> index 1b7720c66ac87..7a67776dca3fe 100644
>>> --- a/include/linux/rmap.h
>>> +++ b/include/linux/rmap.h
>>> @@ -712,9 +712,13 @@ static __always_inline int __folio_try_share_anon_rmap(struct folio *folio,
>>> VM_WARN_ON_FOLIO(!PageAnonExclusive(page), folio);
>>> __folio_rmap_sanity_checks(folio, page, nr_pages, level);
>>>
>>> + /* We only clear anon-exclusive from head page of PMD folio */
>>
>> Is this accurate? David? I thought anon exclusive was per-subpage for any large
>> folio...?
>
>The current behaviour is to do this only. I was also surprised with this,
>so I had dug in and found out:
>
>https://lore.kernel.org/all/20220428083441.37290-13-david@xxxxxxxxxx/
>
>where David says:
>
>"Long story short: once
>PTE-mapped, we have to track information about exclusivity per sub-page,
>but until then, we can just track it for the compound page in the head
>page and not having to update a whole bunch of subpages all of the time
>for a simple PMD mapping of a THP."
>

Thanks for digging.

One tiny thing:

Now we have a comment in PageAnonExclusive(), which says:

/*
* HugeTLB stores this information on the head page; THP keeps it per
* page
*/

This may confuse readers? Not your fault, just want to point it out.

--
Wei Yang
Help you, Help me