unmap_mapping_pages(9)
π unmap_mapping_pages(9) π
okay so bestie, welcome to the Kernel API Manual β this one's a function page, we're in the 9 section, and it's literally all about yeeting pages out of people's address spaces. no cap. let's get into it β¨
πΈ NAME πΈ
unmap_mapping_pages β Unmap pages from processes. that's it, that's the vibe. pages? gone. processes? un-mmaped. slay π«Ά
π SYNOPSIS π
void unmap_mapping_pages (struct address_space *mapping , pgoff_t start
, pgoff_t nr , bool even_cows );
look at her. four args, returns nothing (void), pure main character energy π
π¦ ARGUMENTS π¦
mappingβ thestruct address_spaceholding the pages you wanna unmap. this is the neighborhood, basically, and we're about to evict some residents πstartβ index of the first page to be unmapped. where the demolition starts, iykyk.nrβ how many pages to unmap. and here's the iconic part: pass0and it unmaps all the way to the end of the file. zero means everything, periodt π₯even_cowsβ aboolfor whether to unmap even private COWed pages. yes bestie, even those. π
π DESCRIPTION π
so what she does: she unmaps the pages in this address space from any userspace process that has them mmaped. literally any of them. they had their moment, now they're out π
and the tea on when you'd actually want this: generally, you want to remove COWed pages as well when a file is being truncated β but not when invalidating pages from the page cache. two different situations, two different answers for even_cows, don't mix them up or it's gonna be a whole thing π
π SEE ALSO π
these are all from the Kernel file ./mm/memory.c, and honestly it's a whole friend group:
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_folio(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 the whole group chat. read them, bestie, they're all connected π§
ngl thenr = 0thing is the one people forget β0doesn't mean "do nothing", it means "unmap to end of file". do with that information what you will π
and that's the page!! π this one lives in ./mm, dated October 2026, and it's filed under unmap_mapping_pages(9) β go forth and unmap responsibly, bestie, mwah ππβ¨
π¦ 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