> Introduce vma[_flags]_is_persistent() for the purposes of identifying > mappings that are persistent in the sense that bytes to the mapping stay > there, and bytes read from the mapping are the same unless changed by > actions taken by userland. > > Kernel-owned mappings do not fall into this category, as their owner may > change the contents without the user having initiated it, and nor of course > does memory-mapped I/O. > > We exclude fixed mappings as these are singled out as being unmergeable and > so cannot be guaranteed to persist user data. > > hugetlb mappings are fixed mappings, but their contents are entirely the > user's, so they are explicitly carved out as persistent, as the MADV_DODUMP > check already does. > > It excludes droppable mappings, which by their nature are ephemeral. > > Use this functionality to update the madvise MADV_DODUMP check to test for > persistence rather than open-coding this. > > This replaces the VM_SPECIAL check which means it no longer checks for > VMA_IO_BIT, however this is safe as we have established the invariant that > only kernel-owned mappings may set VMA_IO_BIT, so we implicitly include > these. > > No functional change intended. > > Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review ยท https://sashiko.dev/#/patchset/20260914-b4-mmap-prepare-vma-flag-sanify-v2-0-7d9781ed5...@kernel.org?part=31
