clean_recor...apping_range(9)
πΈ clean_record_shared_mapping_range(9) β from the Kernel API Manual π
okay so bestie, welcome to the glow-up of clean_record_shared_mapping_range(9), straight out of the Kernel API Manual. this one's a mm/mapping_dirty_helpers star and she is booked and busy. let's get into it π«Ά
β¨ NAME β¨
clean_record_shared_mapping_range β clean and record every single pte in an address space range. yes, both. multitasking queen π
π¦ SYNOPSIS π¦
unsigned long clean_record_shared_mapping_range (struct address_space
*mapping , pgoff_t first_index , pgoff_t nr , pgoff_t bitmap_pgoff ,
unsigned long *bitmap , pgoff_t *start , pgoff_t *end );
like, look at that signature. seven whole arguments. she's high-maintenance and we respect it π
π ARGUMENTS π
mappingβ theaddress_spacewe want to clean. the main character of this whole operation β¨first_indexβ the first page offset in the range. where the party starts πnrβ how many incremental page offsets we're covering. literally the guest count.bitmap_pgoffβ the page offset of the first bit inbitmap. yes, bits have an offset too, iykyk.bitmapβ pointer to a bitmap of at leastnrbits. important!! the bitmap needs to cover the whole rangefirst_index..first_index + nr. no half-covering, no gaps, we're not doing that πstartβ pointer to the number of the first set bit inbitmap. it gets modified as new bits are set by the function.endβ pointer to the number of the last set bit inbitmap. none set. the value is modified as new bits are set by the function.
π DESCRIPTION π
so when this function returns, there is no guarantee that a CPU hasn't already dirtied new ptes. (rude, but okay.) however β and this is the key part β it will not clean any ptes not reported in the bitmap. so, what are the guarantees? glad you asked bestie, here's the list:
- All ptes dirty when the function starts executing will end up recorded in the bitmap. slay, no cap π₯
- All ptes dirtied after that will either remain dirty, be recorded in the bitmap, or both. flexible queen π
okay so if a caller needs to be sure all dirty ptes are picked up and none extra get added, they've gotta put in the work: first write-protect the address-space range and make sure new writers are blocked inpage_mkwriteorpfn_mkwrite. and then, after a TLB flush following the write-protection, pick up all the dirty bits. no shortcuts, bestie π€
also ngl, this function currently skips transhuge page-table entries, since it's intended for dirty-tracking on the PTE level. it will warn on encountering transhuge dirty entries though π and it can easily be extended to handle them as well. future upgrade potential, we love to see it β
π RETURN π
the number of dirty ptes actually cleaned. that's it, that's the number π
π§ SEE ALSO π§
- Kernel file
./mm/mapping_dirty_helpers.cβ the source, the origin story π struct wp_walk(9)wp_pte(9)struct clean_walk(9)clean_record_pte(9)wp_shared_mapping_range(9)
go read them, they're iconic, fr fr π
β¨ and that's the whole page!! sourced from ./mm, dated October 2026, and filed under clean_recor...apping_range(9) β yes the header literally abbreviates it like that, we don't make the rules π bye bestie, go clean some ptes π
πΈ
π¦ 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