folio_try_dup_anon_rmap_pmd(9)
π folio_try_dup_anon_rmap_pmd(9) π
okay so bestie, welcome to the Kernel API Manual β this is the page for folio_try_dup_anon_rmap_pmd, and it's literally about trying to duplicate a PMD mapping of a page range of a folio. yes the name is a mouthful, no we are not changing it β¨
πΈ NAME πΈ
folio_try_dup_anon_rmap_pmd β try duplicating a PMD mapping of a page range of a folio π¦
β SYNOPSIS β
int folio_try_dup_anon_rmap_pmd (struct folio *folio , struct page *page
, struct vm_area_struct *dst_vma , struct vm_area_struct *src_vma );
like, four args, one int back. she's giving "small signature, big responsibility" ngl π₯
π ARGUMENTS π
folioβ the folio whose mapping we're duplicating πpageβ the first page whose mapping we're duplicating (first one!! not all of them, keep up π«Ά)dst_vmaβ the destination vm area, aka where it's going π―src_vmaβ the vm area the mapping is being duplicated from, aka where it came from π
β¨ DESCRIPTION β¨
so the page range of the folio is defined by [page, page + HPAGE_PMD_NR) β that's the window, periodt. π
heads up bestie: the caller needs to hold the page table lock and the vma->vma_mm->write_protect_seq. no lock, no service π
duplicating the mapping can only fail if the folio may be pinned. and here's the slay part: device private folios cannot get pinned, and consequently this function cannot fail for them. iconic, honestly π
if duplicating the mapping succeeds, the duplicated PMD has to be R/O in the parent and the child. they must *not* be writable after this call succeeded. read that again. not. π¨
returns 0 if duplicating the mapping succeeded. returns -EBUSY otherwise. that's the whole vibe check π
π¦ SEE ALSO π¦
kernel file ./include/linux/rmap.h, plus the whole squad: folio_dup_file_rmap_ptes(9), folio_dup_file_rmap_pmd(9), folio_try_dup_anon_rmap_ptes(9), folio_try_share_anon_rmap_pte(9), folio_try_share_anon_rmap_pmd(9), page_vma_mapped_walk_restart(9) β go read them, iykyk π
mwah π this page lives in ./include/linux, dated October 2026, and it's folio_try_dup_anon_rmap_pmd(9) forever and always. go forth and don't make those PMDs writable, bestie π«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms