unmap_mapping_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 a PAGE_SIZE boundary ✨ and note that this is different from truncate_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 a PAGE_SIZE boundary. and a holelen of zero truncates to the end of the file. zero means "all the way, bestie" πŸ”₯
  • even_cows β€” set to 1 when you're truncating a file, so you unmap even private COWed pages; but set it to 0 when 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