答复: [PATCH V3] vfio dma_map/unmap: optimized for hugetlbfs pages
From: Maoming (maoming, Cloud Infrastructure Service Product Dept.)
Date: Tue Sep 01 2020 - 08:48:56 EST
>
> > In the original process of dma_map/unmap pages for VFIO-devices, to
> > make sure the pages are contiguous, we have to check them one by one.
> > As a result, dma_map/unmap could spend a long time.
> > Using the hugetlb pages, we can avoid this problem.
> > All pages in hugetlb pages are contiguous.And the hugetlb page should
> > not be split.So we can delete the for loops.
>
> I know nothing about VFIO, but I'm surprised that you're paying such attention
> to PageHuge hugetlbfs pages, rather than to PageCompound
> pages: which would also include Transparent Huge Pages, of the traditional
> anonymous kind, or the huge tmpfs kind, or the more general (not necessarily
> pmd-sized) kind that Matthew Wilcox is currently working on.
>
> It's true that hugetlbfs is peculiar enough that whatever you write for it may
> need some tweaks to cover the THP case too, or vice versa; but wouldn't your
> patch be a lot better for covering all cases?
>
> You mention above that "the hugetlb page should not be split":
> perhaps you have been worried that a THP could be split beneath you?
> That used to be a possibility some years ago, but nowadays a THP cannot be
> split while anyone is pinning it with an extra reference.
>
> Hugh
>
Thanks for your suggestions.
You mention that a THP cannot be split while anyone is pinning it.
Do you mean the check of can_split_huge_page()(in split_huge_page_to_list())?
When we want to pin pages, vfio_pin_pages_remote() always gets a normal page first.
In this case, a THP cannot be split because of the increased reference.
Is this right?
Maybe I can optimize for hugetlb pages as a first step, and then cover all compound pages.