wp_shared_mapping_range(9)
π 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β theaddress_spacewe 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 fromfirst_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 π§
- Kernel file
./mm/mapping_dirty_helpers.c struct wp_walk(9)wp_pte(9)struct clean_walk(9)clean_record_pte(9)clean_record_shared_mapping_range(9)
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
- 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