Re: [PATCH V4 1/2] vfio dma_map/unmap: optimized for hugetlbfs pages

From: Jason Gunthorpe
Date: Wed Sep 09 2020 - 10:21:05 EST

On Wed, Sep 09, 2020 at 09:01:14AM +0100, Christoph Hellwig wrote:
> I really don't think this approach is any good. You workaround
> a deficiency in the pin_user_pages API in one particular caller for
> one particular use case.

RDMA has the same basic issues, this should should not be solved with
workarounds in VFIO - a common API would be good

> I think you'd rather want either:
> (1) a FOLL_HUGEPAGE flag for the pin_user_pages API family that returns
> a single struct page for any kind of huge page, which would also
> benefit all kinds of other users rather than adding these kinds of
> hacks to vfio.

How to use? The VMAs can have mixed page sizes so the caller would
have to somehow switch and call twice? Not sure this is faster.

> (2) add a bvec version of the API that returns a variable size
> "extent"

This is the best one, I think.. The IOMMU setup can have multiple page
sizes, so having largest contiguous blocks pre-computed should speed
that up.

vfio should be a win to use a sgl rather than a page list?

Especially if we can also reduce the number of pages pinned by only
pinning head pages..

> I had started on (2) a while ago, and here is branch with my code (which
> is broken and fails test, but might be a start):
> But for now I wonder if (1) is the better start, which could still be
> reused to (2) later.

What about some 'pin_user_page_sgl' as a stepping stone?

Switching from that point to bvec seems like a smaller step?