Re: [PATCH] vfio: Request THP-aligned mmap for device fds

From: Matthew Wilcox

Date: Fri Jun 19 2026 - 12:12:11 EST


On Thu, Jun 18, 2026 at 12:28:05PM -0300, Jason Gunthorpe wrote:
> On Thu, Jun 18, 2026 at 03:55:58PM +0100, Lorenzo Stoakes wrote:
> > Can't we figure this out from what the driver tells us when it invokes an
> > mmap_prepare action?
>
> VFIO installs the pages via fault handler so there is not a naturally
> existing way to pass in the pfn?

Is there an advantage to doing it this way? I understand why we (eg)
demand-page pagecache, that's obvious. But I've never really understood
the advantage to taking page faults for PFNMAP areas where we don't
really do anything, just figure out which PFN needs to be installed.
It defers page table allocation, I suppose.

> > Not in favour of that, fear it'll be seen as a new go-faster stripe. Ask
> > somebody how many free pints they want and they may veer rather towards the
> > upper bound :)
>
> I think you need something, otherwise we will be aligning VMAs that
> never have anything larger than a 2M THP to 1GB boundaries, doesn't
> seem good.

If Lorenzo's willing to move the mmap_prepare call earlier, to before we
allocate the vma then we can do it that way ...