I want to track down which pages of a memory region mapped with mmap
have been modified.
Can the dirtiness of pages of a mmap be found from userspace? porved to be pretty useful.
On linux (ubuntu @ 5.15.0-46-generic) I can see once the memory is mapped all pages are marked dirty (the SOFT-DIRTY page table entry bit) in the /proc/pid/pagemap
file. Doing an echo 4 >> /proc/pid/clear_refs
clears the bit. Every write in the mapped regio sets the appropriate page's dirty bit, as expected(?).
On Android (Android 12 AOSP @ 5.10.43-android12-9-00005-g740f7fbe5f39-ab7943734) that't not the case though. When a region is mapped, the dirty bit is 0. Writing to the region still does not raise the soft-dirty bit.
Any ideas why Android is behaving differently and/or if it's possible to control that behavior and how?