v2
2026-11-04
mremap部分移动统计修正 · v2
v2 在 mremap 移动前预拆分 VMA,使拆分失败可提前报告;另修复 hugetlb 预留映射被整体移走导致保留部分未归还。
原始补丁链接
子 Patch(5)
1/5
mm/mremap: fix hugetlb reservation leak on partial move
Moving a part of a private hugetlb mapping with mremap() leaks the huge page reservations of the parts that stay. They are not returned when the mapping is unmapped, when the process exits or when the
2/5
selftests/mm: test a partial mremap() of hugetlb memory
hugetlb-mremap only moves whole mappings, so it did not catch the reservation leak of a partial move. Map four private huge pages without touching them, move the second one, unmap everything, and che
3/5
mm/mremap: reaccount on unmap failure only if accounted
When the unmap of the source range fails at the end of an mremap() move, the length of the range is charged to vm_committed_as even if the VMA was never accounted, for example a MAP_SHARED or MAP_NORE
4/5
mm/mremap: restore VMA_ACCOUNT_BIT if the unmap fails
If the unmap at the end of an mremap() move fails, the source VMA stays without VMA_ACCOUNT_BIT. Neither munmap() nor exit_mmap() uncharges it then, so the charge for all of its pages stays in vm_comm
5/5
selftests/mm: test mremap() with an old size of 0
mremap() with an old size of 0 duplicates a shared mapping, and mremap_test has no case for it. Duplicate a shared anonymous mapping, once from its start and once from the middle. Check that the sour