folio_add_new_anon_rmap(9)
β¨ 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:
__anon_vma_prepare(9)anon_vma_clone(9)unlink_anon_vmas(9)page_address_in_vma(9)folio_referenced(9)mapping_wrprotect_range(9)pfn_mkclean_range(9)folio_move_anon_rmap(9)__folio_set_anon(9)__page_check_anon_rmap(9)folio_add_anon_rmap_ptes(9)folio_add_anon_rmap_pmd(9)folio_add_file_rmap_ptes(9)folio_add_file_rmap_pmd(9)folio_add_file_rmap_pud(9)folio_remove_rmap_ptes(9)folio_remove_rmap_pmd(9)folio_remove_rmap_pud(9)try_to_unmap(9)try_to_migrate(9)make_device_exclusive(9)__rmap_walk_file(9)
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
- 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