Re: [PATCH 5/5] vfio-pci: Best-effort huge pfnmaps with !MAP_FIXED mappings
From: Peter Xu
Date: Tue Jun 17 2025 - 16:56:42 EST
On Mon, Jun 16, 2025 at 08:00:11PM -0300, Jason Gunthorpe wrote:
> On Mon, Jun 16, 2025 at 06:06:23PM -0400, Peter Xu wrote:
>
> > Can I understand it as a suggestion to pass in a bitmask into the core mm
> > API (e.g. keep the name of mm_get_unmapped_area_aligned()), instead of a
> > constant "align", so that core mm would try to allocate from the largest
> > size to smaller until it finds some working VA to use?
>
> I don't think you need a bitmask.
>
> Split the concerns, the caller knows what is inside it's FD. It only
> needs to provide the highest pgoff aligned folio/pfn within the FD.
Ultimately I even dropped this hint. I found that it's not really
get_unmapped_area()'s job to detect over-sized pgoffs. It's mmap()'s job.
So I decided to avoid this parameter as of now.
>
> The mm knows what leaf page tables options exist. It should try to
> align to the closest leaf page table size that is <= the FD's max
> aligned folio.
So again IMHO this is also not per-FD information, but needs to be passed
over from the driver for each call.
Likely the "order" parameter appeared in other discussions to imply a
maximum supported size from the driver side (or, for a folio, but that is
definitely another user after this series can land).
So far I didn't yet add the "order", because currently VFIO definitely
supports all max orders the system supports. Maybe we can add the order
when there's a real need, but maybe it won't happen in the near future?
In summary, I came up with below changes, would below look reasonable?
I also added Liam and Lorenzo in this reply.
================8<================