unmap_mapping_range(9)
π unmap_mapping_range
okay bestie, welcome to the unmap_mapping_range page from the Kernel API Manual β yes, that's the manual name, we're fancy like that π
β¨ NAME β¨
unmap_mapping_range β literally unmap the portion of all mmaps in the specified address_space that corresponds to the specified byte range in the underlying file. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
void unmap_mapping_range (struct address_space *mapping , loff_t const
holebegin , loff_t const holelen , int even_cows );
no cap, that's the exact signature, copy it exactly please π
π¦ ARGUMENTS π¦
mappingβ the address space that's holding the mmaps you want unmapped. it's giving "which friend group are we removing from the chat" energy π«Άholebeginβ the byte in the first page to unmap, measured relative to the start of the underlying file. heads up: this gets rounded down to aPAGE_SIZEboundary β¨ and note that this is different fromtruncate_pagecache, which must keep the partial page. we, in contrast, must get rid of partial pages. no partial pages allowed, periodt πholelenβ the size of the prospective hole, in bytes. this one gets rounded up to aPAGE_SIZEboundary. and aholelenof zero truncates to the end of the file. zero means "all the way, bestie" π₯even_cowsβ set to1when you're truncating a file, so you unmap even private COWed pages; but set it to0when you're invalidating pagecache, because then you don't throw away private data. pick wisely, this is the main character decision of the whole call π
π SEE ALSO π
this is the whole Kernel file ./mm/memory.c crew, and they're all here, every single one, no gatekeeping π§:
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_pages(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 is a lot of friends and we are not skipping any of them. iykyk π
π okay that's the whole page, you ate that. this one came out of ./mm in October 2026, so 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