On 10/21/26 22:43, Zi Yan wrote:
> On 21 Oct 2026, at 16:36, Konstantin Khorenko wrote:
>
>> folio_dup_file_rmap_pmd() passes PGTABLE_LEVEL_PTE to
>> __folio_dup_file_rmap() for HPAGE_PMD_NR pages, so it adds HPAGE_PMD_NR
>> PTE mappings to the folio instead of one PMD mapping. Each unmap of the
>
>
>> PMD removes one PMD mapping:
>>
>> - the folio's mapcount never returns to zero, and removing the folio
>> from the page cache reports "Bad page cache", or hits a VM_BUG_ON
>> with CONFIG_DEBUG_VM;
>> - the first unmap already counts as the last one and drops the
>> PMD-mapped statistics while the other mm still maps the folio;
>> - the second one drives the entire mapcount below zero and drops them
>> again.
>
> This chunk of text probably can go away, since no one is affected
> by the code.
Sure, will drop it once we are ready for the next iteration.
Thank you!
>> The helper has no caller yet, the next patch adds the first one. Pass
>> PGTABLE_LEVEL_PMD, as folio_try_dup_anon_rmap_pmd() does.
>>
>> Fixes: d8ef5e311d7b ("mm/rmap: convert page_dup_file_rmap() to
>> folio_dup_file_rmap_[pte|ptes|pmd]()")
>> Signed-off-by: Konstantin Khorenko <[email protected]>
>> ---
>> include/linux/rmap.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>
> The code change looks good to me. I also find this when I am working
> on PG_folio. Thanks.
>
> Reviewed-by: Zi Yan <[email protected]>
>
>
> Best Regards,
> Yan, Zi