folio_try_du...on_rmap_ptes(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

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

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