How can I improve SPDK performance on userspace DMA access?

403 views Asked by At

I am working on a userspace PCI driver which uses SPDK/VFIO APIs to do dma access.

Currently for each DMA allocation request I need to fill up structure spdk_vfio_dma_map then call system call ioctl(fd, VFIO_IOMMU_MAP_DMA, &dma_map) to map the DMA region through IOMMU. Then later call ioctl(fd, VFIO_IOMMU_UNMAP_DMA, &dma_map) to unmap the IOMMU mapping.

This is working fine so far and looks like it's what SPDK examples are using. However I am wondering if there is a way to pre-allocate all memory buffer in userspace then in each DMA allocation request just use the pre-allocated memory instead of doing ioctl call each time?

Any idea is well appreciated.

1

There are 1 answers

0
BeginEnd On BEST ANSWER

Don't know if I get the issue but the whole idea (of DPDK and SPDK) is to allocate all the memory you are using on application start or driver probe.

If you are using memory that is under application control all the time then you don't need to do VFIO_IOMMU_MAP_DMA and VFIO_IOMMU_UNMAP_DMA every DMA transaction. If this is not the case you have two options:

  1. Do the VFIO_IOMMU_MAP_DMA and VFIO_IOMMU_UNMAP_DMA for every IO
  2. Copy the payload to the memory that is already registered in VFIO_IOMMU_MAP_DMA.

First option is better for huge memory blocks, while second is better for small IO chunks.