folio_try_dup_anon_rmap_pmd(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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