wp_shared_mapping_range(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… wp_shared_mapping_range(9) πŸ’…

ok so this is a page from the Kernel API Manual (section 9, kernel devs only, iykyk) and honestly? it's giving "small function, big responsibilities." let's get into it ✨


🌸 NAME 🌸

wp_shared_mapping_range β€” write-protect all the ptes in an address space range, bestie. every single one. no crumbs left behind πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

unsigned long wp_shared_mapping_range (struct address_space *mapping ,
pgoff_t first_index , pgoff_t nr );

like look at that signature. so clean. so intentional. and yes it returns an unsigned long, keep that in your notes πŸ“


πŸŽ€ ARGUMENTS πŸŽ€

  • mapping β€” the address_space we want to write protect. this is the main character of the whole operation, fr fr πŸ‘‘
  • first_index β€” the first page offset in the range. where the vibes begin ✨
  • nr β€” number of incremental page offsets to cover. so like, how far we're walking from first_index, one page offset at a time 🌈

😭 NOTE 😭

ok important heads-up, bestie. this function currently skips transhuge page-table entries, because it's intended for dirty-tracking on the PTE level. that's the whole design rn, no cap.

but πŸ‘€ β€” it will warn on encountering transhuge write-enabled entries. and lowkey it can easily be extended to handle them as well, so it's not a permanent situation, it's just the current vibe check. so if you see that warning, that's why πŸ’€


🫢 RETURN 🫢

it returns the number of ptes actually write-protected. and here's the lil gotcha that trips people up: already write-protected ptes are not counted. so don't @ me when your count is lower than you expected β€” that's literally the design πŸ™ˆ


🧚 SEE ALSO 🧚

go read the whole little family, they're all in on the same dirty-tracking plot πŸ“


⭐ sign-off ⭐

this page lives in ./mm from October 2026 β€” go off, kernel docs πŸ’œ slay, stay write-protected, and remember: skipping transhuge entries is a feature, not a bug (for now) πŸ’…βœ¨

πŸ“¦ where this page comes from