On Fri, Jan 09, 2026 at 02:50:26PM +0100, David Hildenbrand (Red Hat) wrote:
We now handle file-backed folios correctly I think. Could we somehow also be in trouble for anon folios? Because there, we'd still take the rmap lock after grabbing the folio lock.
We're now pretty far afield from my area of MM expertise, but since using AI is now encouraged, I will confidently state that only file-backed hugetlb folios have this inversion of the rmap lock and folio lock. anon hugetlb folios follow the normal rules. And it's all because of PMD sharing, which isn't needed in the anon case but is needed for file-backed.
So once mshare is in, we can remove this wart.
if (page_was_mapped)
remove_migration_ptes(src, !rc ? dst : src, 0);
remove_migration_ptes(src, !rc ? dst : src,ttu ? RMP_LOCKED : 0);(ttu & TTU_RMAP_LOCKED) ? RMP_LOCKED : 0)
Would be cleaner, but I see how you clean that up in #2. :)
Yes, that would be more future-proof, but this code has no future ;-)
Acked-by: David Hildenbrand (Red Hat) david@kernel.org
Thanks!