folio_add_new_anon_rmap(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ folio_add_new_anon_rmap ✨

okay bestie, so this one is a kernel API manual page, like from the Kernel API Manual bestie, and we're literally about to get into it πŸ’…

🌸 NAME 🌸

folio_add_new_anon_rmap β€” add mapping to a new anonymous folio. periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

void folio_add_new_anon_rmap (struct folio *folio , struct
       vm_area_struct *vma , unsigned long address , rmap_t flags );

πŸŽ€ ARGUMENTS πŸŽ€

  • folio β€” the folio we're adding the mapping to, bestie. that's the main character right there.
  • vma β€” the vm area in which the mapping is added. it's giving "where the vibe lives".
  • address β€” the user virtual address mapped. literally the address, no cap.
  • flags β€” the rmap flags. yes queen, flags.

πŸ’– DESCRIPTION πŸ’–

so this is like folio_add_anon_rmap_*() but bestie… it must only be called on new folios. i cannot stress this enough like fr fr. this means the inc-and-test can be bypassed β€” slay, we skip that step.

the folio doesn't necessarily need to be locked while it's exclusive, unless two threads map it concurrently (messy, avoid). however β€” and this is the important part β€” the folio must be locked if it's shared. like, do not come for me if you skip this, i warned you πŸ˜­πŸ’€

if the folio is pmd-mappable, it is accounted as a THP. that's it, that's the tea πŸ“.

lowkey a vibe check: new folios only, lock it if shared, no exceptions 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

kernel file ./mm/rmap.c:


and that's the whole page, bestie β€” no crumbs left behind πŸ’…βœ¨ this iconic lil manual page lives in ./mm, dated October 2026, and it's literally called folio_add_new_anon_rmap(9). go off, kernel queen πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from