Re: [PATCH v2 3/4] mm/huge_memory: don't warn when a page table blocks a huge pfn insert
From: Andrew Morton
Date: Thu Nov 12 2026 - 22:29:24 EST
On Thu, 12 Nov 2026 05:14:39 +0000 Eliav Farber <farbere@xxxxxxxxxx> wrote:
> insert_pmd() and insert_pud() treat a non-empty entry at their own level
> as a leaf and compare its PFN against the one being inserted. A page
> table installed by a concurrent order-0 fault also makes the entry
> non-empty, and pmd_pfn()/pud_pfn() then report the PFN of that table,
> which never matches. insert_pmd() warns unless the entry is the huge
> zero PMD, and insert_pud() warns on any mismatch.
>
> A VM_PFNMAP mapping with both ->fault and ->huge_fault can produce the
> mixed orders: an order-0 fault installs a page table over an address
> while a concurrent huge fault on the same address reaches insert_pmd().
> Changing an mm's THP policy while another thread faults the same PMD,
> for example with prctl(PR_SET_THP_DISABLE), is enough to do it.
>
> Compare the PFN only for a leaf entry. A page table is not an error, so
> take the existing out_unlock path, which returns VM_FAULT_NOPAGE and
> lets the access refault onto the smaller entry.
Thanks. Sashiko says this fixes a cant-happen.
https://sashiko.dev/#/patchset/20261112051440.16140-1-farbere@xxxxxxxxxx
> Fixes: f9e54c3a2f5b ("vfio/pci: implement huge_fault support")
But that's because Sashiko only considered f9e54c3a2f5b.
It seems that DRM shmem and Panthor and mshv pass FAULT_FLAG_WRITE and
can reach the warnings.
So... patch looks good but the Fixes: might be inaccurate.
Fixes: c6f3c5ee40c1 ("mm/huge_memory.c: fix modifying of page protection by insert_pfn_pmd()")
might be better.
Also, we don't want current production kernels to do this so please
consider adding an explicit cc:stable to the patch.