unmap_mapping_pages(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” the struct address_space holding 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: pass 0 and it unmaps all the way to the end of the file. zero means everything, periodt πŸ”₯
  • even_cows β€” a bool for 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:

like, that's the whole group chat. read them, bestie, they're all connected 🧚


ngl the nr = 0 thing is the one people forget β€” 0 doesn'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