unmap_mapping_folio(9)
β¨ unmap_mapping_folio β¨
okay so bestie, this is a page from the Kernel API Manual and it's about one (1) folio getting yeeted out of everybody's address space π literally the "you don't have to go home but you can't stay here" of memory management π
πΈ NAME πΈ
unmap_mapping_folio β unmap a single folio from processes. That's it. One folio. Unmapped. Periodt. β¨
π¦ SYNOPSIS π¦
void unmap_mapping_folio (struct folio *folio );
the way it just takes one argument and returns voidβ¦ lowkey iconic π«Ά
π ARGUMENTS π
folioβ the locked folio that's about to be unmapped π heads up though: it's locked, bestie, so don't come in here without holding that lock, iykyk π
π§ DESCRIPTION π§
okay so picture this: this folio is mmaped into some userspace process somewhere, right? and unmap_mapping_folio goes and unmaps it from any userspace process that still has it mmaped. no survivors. no cap. π
typically β and this is the efficiency era of it all β the range of nearby pages has already been unmapped, by unmap_mapping_pages or by unmap_mapping_range. so usually the bulk of the work is done and this is just the cleanup girlie β¨
but here's the plot twist π once truncation or invalidation holds the lock on a folio, it might find that the page has been remapped again. like, it came back?? rude?? and that's exactly when it reaches for unmap_mapping_folio to unmap it finally. last one out, turn off the lights π―οΈ
π SEE ALSO π
so many references, bestie, this page has main character energy in the cross-reference department π all from the kernel file ./mm/memory.c:
free_pgd_range(9)free_pgtables(9)__vm_normal_page(9)vm_normal_page(9)vm_normal_folio(9)vm_normal_page_pmd(9)vm_normal_folio_pmd(9)vm_normal_page_pud(9)restore_exclusive_pte(9)cond_install_uffd_wp_ptes(9)zap_vma_for_reaping(9)unmap_vmas(9)zap_vma_range_batched(9)zap_vma_range(9)zap_special_vma_range(9)vm_insert_pages(9)vm_insert_page(9)vm_map_pages(9)vm_map_pages_zero(9)vmf_insert_pfn_prot(9)vmf_insert_pfn(9)remap_pfn_range(9)vm_iomap_memory(9)__vmf_anon_prepare(9)finish_mkwrite_fault(9)unmap_mapping_pages(9)unmap_mapping_range(9)set_pte_range(9)finish_fault(9)mm_account_fault(9)follow_pfnmap_start(9)follow_pfnmap_end(9)generic_access_phys(9)access_remote_vm(9)copy_remote_vm_str(9)folio_zero_user(9)
likeβ¦ that's a whole friend group π«Ά go read them, they're all slaying in their own way π
ok and one lil sign-off π this page lives in./mm, dated October 2026, and if you ever need to find it again it's filed underunmap_mapping_folio(9). mwah, go touch some pages πβ¨
π¦ 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