• Changbin Du's avatar
    drm/i915/gvt: Fix guest vGPU hang caused by very high dma setup overhead · cf4ee73f
    Changbin Du authored
    The implementation of current kvmgt implicitly setup dma mapping at MPT
    API gfn_to_mfn. First this design against the API's original purpose.
    Second, there is no unmap hit in this design. The result is that the
    dma mapping keep growing larger and larger. For mutl-vm case, they will
    consume IOMMU IOVA low 4GB address space quickly and so tons of rbtree
    entries crated in the IOMMU IOVA allocator. Finally, single IOVA
    allocation can take as long as ~70ms. Such latency is intolerable.
    To address both above issues, this patch introduced two new MPT API:
      o dma_map_guest_page - setup dma map for guest page
      o dma_unmap_guest_page - cancel dma map for guest page
    The kvmgt implements these 2 API. And to reduce dma setup overhead for
    duplicated pages (eg. scratch pages), two caches are used: one is for
    mapping gfn to struct gvt_dma, another is for mapping dma addr to
    struct gvt_dma.
    With these 2 new API, the gtt now is able to cancel dma mapping when page
    table is invalidated. The dma mapping is not in a gradual increase now.
    v2: follow the old logic for VFIO_IOMMU_NOTIFY_DMA_UNMAP at this point.
    Cc: Hang Yuan <hang.yuan@intel.com>
    Cc: Xiong Zhang <xiong.y.zhang@intel.com>
    Signed-off-by: default avatarChangbin Du <changbin.du@intel.com>
    Signed-off-by: Zhenyu Wang's avatarZhenyu Wang <zhenyuw@linux.intel.com>
gtt.c 60.4 KB