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

From: Matthew Wilcox
Date: Wed Sep 09 2020 - 12:02:40 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.
> 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.

This seems to be similar to a flag I added last week to
pagecache_get_page() called FGP_HEAD:

+ * * %FGP_HEAD - If the page is present and a THP, return the head page
+ * rather than the exact page specified by the index.

I think "return the head page" is probably what we want from what I
understand of this patch. The caller can figure out the appropriate
bv_offset / bv_len for a bio_vec, if that's what they want to do with it. is the exact commit where I added that, but it depends on a number of other patches in this series:

I'm going to send out a subset of patches later today which will include
that one and some others. I haven't touched the GUP paths at all in
that series, but it's certainly going to make THPs (of various sizes)
much more present in the system.