Re: [RFC RESEND 00/16] Split IOMMU DMA mapping operation to two steps

From: Christoph Hellwig
Date: Thu Mar 21 2024 - 18:39:34 EST


On Tue, Mar 19, 2024 at 12:36:20PM -0300, Jason Gunthorpe wrote:
> I kind of understand your thinking on the DMA side, but I don't see
> how this is good for users of the API beyond BIO.
>
> How will this make RDMA better? We have one MR, the MR has pages, the
> HW doesn't care about the SW distinction of p2p, swiotlb, direct,
> encrypted, iommu, etc. It needs to create one HW page list for
> whatever user VA range was given.

Well, the hardware (as in the PCIe card) never cares. But the setup
path for the IOMMU does, and something in the OS needs to know about
it. So unless we want to stash away a 'is this P2P' flag in every
page / SG entry / bvec, or a do a lookup to find that out for each
of them we need to manage chunks at these boundaries. And that's
what I'm proposing.

> Or worse, whatever thing is inside a DMABUF from a DRM
> driver. DMABUF's can have a (dynamic!) mixture of P2P and regular
> AFAIK based on the GPU's migration behavior.

And that's fine. We just need to track it efficiently.

>
> Or triple worse, ODP can dynamically change on a page by page basis
> the type depending on what hmm_range_fault() returns.

Same. If this changes all the time you need to track it. And we
should find a way to shared the code if we have multiple users for it.

But most DMA API consumers will never see P2P, and when they see it
it will be static. So don't build the DMA API to automically do
the (not exactly super cheap) checks and add complexity for it.

> So I take it as a requirement that RDMA MUST make single MR's out of a
> hodgepodge of page types. RDMA MRs cannot be split. Multiple MR's are
> not a functional replacement for a single MR.

But MRs consolidate multiple dma addresses anyway.

> Go back to the start of what are we trying to do here:
> 1) Make a DMA API that can support hmm_range_fault() users in a
> sensible and performant way
> 2) Make a DMA API that can support RDMA MR's backed by DMABUF's, and
> user VA's without restriction
> 3) Allow to remove scatterlist from BIO paths
> 4) Provide a DMABUF API that is not scatterlist that can feed into
> the new DMA API - again supporting DMABUF's hodgepodge of types.
>
> I'd like to do all of these things. I know 3 is your highest priority,
> but it is my lowest :)

Well, 3 an 4. And 3 is not just limited to bio, but all the other
pointless scatterlist uses.