Re: [RFC PATCH 3/3] KVM: x86/mmu: skip zap maybe-dma-pinned pages for NUMA migration
From: Yan Zhao
Date: Wed Aug 09 2023 - 01:33:13 EST
On Tue, Aug 08, 2023 at 04:56:11PM -0700, Sean Christopherson wrote:
> and then for PG_anon_exclusive
>
> * ... For now, we only expect it to be
> * set on tail pages for PTE-mapped THP.
> */
> PG_anon_exclusive = PG_mappedtodisk,
>
/*
* Depending on the way an anonymous folio can be mapped into a page
* table (e.g., single PMD/PUD/CONT of the head page vs. PTE-mapped
* THP), PG_anon_exclusive may be set only for the head page or for
* tail pages of an anonymous folio. For now, we only expect it to be
* set on tail pages for PTE-mapped THP.
*/
PG_anon_exclusive = PG_mappedtodisk,
Now sure why the comment says PG_anon_exclusive is set only on tail
pages for PTE-mapped THP,
what I observed is that only head page of a compound page is set to
anon_exclusive.
And the code path is here:
__handle_mm_fault
|->create_huge_pmd
|->do_huge_pmd_anonymous_page //if (vma_is_anonymous(vmf->vma)
|->folio = vma_alloc_folio(gfp, HPAGE_PMD_ORDER, vma, haddr, true);
|->__do_huge_pmd_anonymous_page(vmf, &folio->page, gfp);
|->folio_add_new_anon_rmap
|->__page_set_anon_rmap(folio, &folio->page, vma, address, 1);
|->SetPageAnonExclusive(page)
And this code path has been present since
6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive")