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

From: Lorenzo Stoakes

Date: Sat Jul 11 2026 - 04:38:26 EST


On 2026-06-30 09:46 -0300, Jason Gunthorpe wrote:
> On Mon, Jun 22, 2026 at 05:54:10PM +0100, Lorenzo Stoakes wrote:
> > On Fri, Jun 19, 2026 at 10:16:58AM -0300, Jason Gunthorpe wrote:
> > > On Thu, Jun 18, 2026 at 04:56:06PM +0100, Lorenzo Stoakes wrote:
> > > > > > What you're saying is that offset 0 of the opened file might correspond
> > > > > > to a PFN that is not aligned in any way? I had assumed that when trying
> > > > > > to do the mapping of (2MB+4KiB to 64MB), that the offset specified to
> > > > > > mmap was 2MB+4KiB. But you seem to be saying that the offset in that
> > > > > > case would be 0 and someone needs to know that it corresponds to a PFN
> > > > > > that is misaligned?
> > > > >
> > > > > I do expect that the pgoff space is usually aligned to the pfn space,
> > > > > most drivers do that or could be improved to do that. There will be
> > > > > some off cases, but maybe we don't care, and VFIO should be fine.
> > > >
> > > > Some stuff has weird assumptions about pfn=0 at start of the range (DMA for
> > > > instance).
> > >
> > > Do you have a pointer? I'm drawing a blank what "dma" is?
> >
> > (I am obliged to link https://xkcd.com/138/... :)
> >
> > dmabuf as in [0], where vma->vm_pgoff must be the page offset
> > into the DMA buffer.
> >
> > [0]:https://elixir.bootlin.com/linux/v7.1/source/kernel/dma/direct.c#L550
>
> That's not "dmabuf" that is the DMA API's dma_mmap() interface, very
> different thing. This could probably be reworked if it is some issue..

Yeah right that's what I mean. And I plan to do some rework around that as part
of mmap_prepare() I have some slightly bitrotting patches for this that I'll
shake down at some point...

>
> Jason
>

Cheers, Lorenzo