Re: [tip: x86/mm] x86/mm/pat: Fix VM_PAT handling when fork() fails in copy_page_range()

From: David Hildenbrand
Date: Wed Mar 19 2025 - 04:16:04 EST


+void untrack_pfn_copy(struct vm_area_struct *dst_vma,
+ struct vm_area_struct *src_vma)
+{
+ resource_size_t paddr;
+ unsigned long size;
+
+ if (!(dst_vma->vm_flags & VM_PAT))
+ return;
+
+ /*
+ * As the page tables might not have been copied yet, the PAT
+ * information is obtained from the src VMA, just like during
+ * track_pfn_copy().
+ */
+ if (get_pat_info(src_vma, &paddr, NULL)) {
+ size = src_vma->vm_end - src_vma->vm_start;
+ free_pfn_range(paddr, size);
}

@Ingo, can you drop this patch for now? It's supposed to be "!get_pat_info" here, and I want to re-verify now that a couple of months passed, whether it's all working as expected with that.

(we could actually complain if get_pat_info() would fail at this point, let me think about that)

I'll resend once I get to it. Thanks!

--
Cheers,

David / dhildenb