folio_try_du...on_rmap_ptes(9)
π folio_try_dup_anon_rmap_ptes(9) β the Kernel API Manual, bestie edition
okay so this is a page from the Kernel API Manual, and the star of the show is folio_try_dup_anon_rmap_ptes β yes that's a mouthful, yes it's iconic, and yes we're gonna get through it together π«Ά
β¨ NAME β¨
folio_try_dup_anon_rmap_ptes β literally the function that tries to duplicate the PTE mappings of a page range of a folio. that's the whole vibe. duplicating. PTE mappings. a page range. of a folio. π
πΈ SYNOPSIS πΈ
int folio_try_dup_anon_rmap_ptes (struct folio *folio , struct page
*page , int nr_pages , struct vm_area_struct *dst_vma ,
struct vm_area_struct *src_vma );
it returns an int, bestie. remember that, it comes back later π
π ARGUMENTS π
here's the cast, and ngl every single one of them is a main character:
folioβ the folio whose mappings we're duplicating. the whole point, tbh.pageβ the first page whose mappings get duplicated. not the last, the first. keep up β¨nr_pagesβ how many pages we're duplicating the mapping of. the count. the number. the quantity πdst_vmaβ the destination vm area (where the mappings are going to πββοΈ)src_vmaβ the vm area the mappings are being duplicated from (the origin story π)
π₯ DESCRIPTION π₯
so first things first: the page range of the folio is defined by [page, page + nr_pages) β half-open interval, very math, very demure π
the caller needs to hold the page table lock and the vma->vma_mm->write_protect_seq. no cap, you must be holding both. this is not a suggestion, it's giving prerequisite.
duplicating the mappings can only fail if the folio may be pinned β and device private folios cannot get pinned, so consequently this function cannot fail for them. slay for them honestly, they get the easy life π
if duplicating the mappings succeeded, the duplicated PTEs have to be R/O in the parent and the child. they must not be writable after this call succeeded. like, at all. read-only. periodt. π
returns 0 if duplicating the mappings succeeded. returns -EBUSY otherwise. that's it, that's the whole return situation π
π¦ SEE ALSO π¦
- Kernel file
./include/linux/rmap.hβ the home base, the HQ, the address π‘ folio_dup_file_rmap_ptes(9)folio_dup_file_rmap_pmd(9)folio_try_dup_anon_rmap_pmd(9)folio_try_share_anon_rmap_pte(9)folio_try_share_anon_rmap_pmd(9)page_vma_mapped_walk_restart(9)
go read those too, iykyk π
and that's the whole page! sourced from ./include/linux, dated October 2026, filed under folio_try_du...on_rmap_ptes(9) β mwah, go duplicate some mappings responsibly, 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