Skip to content

RFC vfio/iommu_type1: Implement dirty log tracking based on IOMMU HWDBM

Keqian Zhu kvm lkml oe-kbuild-all 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest3 patches 0 repliesNew
  2. v13 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Use separate ioctl to get dirty log without clear it automatically. (Alex)
- Implement based on new iommu dirty tracking framework.
- Track hwdbm status at domain level.
- Bugfix: When get_no_clear, we should recover dirty bitmap too.
- Bugfix: When switch from full dirty policy to iommu hwdbm policy, we should populate full dirty.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3vfio/iommu_type1: Add HWDBM status maintenancedrivers/vfio/vfio_iommu_type1.c+25 -00 replies
2/3vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBMdrivers/vfio/vfio_iommu_type1.c+172 -80 replies
3/3vfio/iommu_type1: Add support for manual dirty log cleardrivers/vfio/vfio_iommu_type1.c include/uapi/linux/vfio.h+142 -80 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [RFC PATCH v2 0/3] vfio/iommu_type1: Implement dirty log tracking based on IOMMU HWDBM

Hi Alex and everyone,

This patch series implement vfio dma dirty log tracking based on IOMMU HWDBM (hardware dirty bit management, such as SMMU with HTTU or intel IOMMU with SLADE).

This patch series is split from the series[1] that containes both IOMMU part and VFIO part. Please refer the new IOMMU part v4[2] to review or test.

Changelog:

v2:
- Use separate ioctl to get dirty log without clear it automatically. (Alex)
- Implement based on new iommu dirty tracking framework.
- Track hwdbm status at domain level.
- Bugfix: When get_no_clear, we should recover dirty bitmap too.
- Bugfix: When switch from full dirty policy to iommu hwdbm policy, we should populate full dirty.

Intention:

As we know, vfio live migration is an important and valuable feature, but there are still many hurdles to solve, including migration of interrupt, device state, DMA dirty log tracking, and etc.

For now, the only dirty log tracking interface is pinning. It has some drawbacks:
1. Only smart vendor drivers are aware of this.
2. It's coarse-grained, the pinned-scope is generally bigger than what the device actually access.
3. It can't track dirty continuously and precisely, vfio populates all pinned-scope as dirty. So it doesn't work well with iteratively dirty log handling.

About this series:

Implement a new dirty log tracking method for vfio based on iommu hwdbm. A new ioctl operation named VFIO_DIRTY_LOG_MANUAL_CLEAR is added, which can eliminate some redundant dirty handling of userspace.

Optimizations Todo:

1. We recognized that each smmu_domain (a vfio_container may has several smmu_domain) has its own stage1 mapping, and we must scan all these mapping to sync dirty state. We plan to refactor smmu_domain to support more than one smmu in one smmu_domain, then these smmus can share a same stage1 mapping.
2. We also recognized that scan TTD is a hotspot of performance. Recently, I have implement a SW/HW conbined dirty log tracking at MMU side[3], which can effectively solve this problem. This idea can be applied to smmu side too.

Thanks,
Keqian

[1] https://lore.kernel.org/linux-iommu/[email protected]/
[2] https://lore.kernel.org/linux-iommu/[email protected]/
[3] https://lore.kernel.org/linux-arm-kernel/[email protected]/

Kunkun Jiang (3):
vfio/iommu_type1: Add HWDBM status maintenance vfio/iommu_type1: Optimize dirty bitmap population based on iommu
HWDBM
vfio/iommu_type1: Add support for manual dirty log clear

 drivers/vfio/vfio_iommu_type1.c | 315 ++++++++++++++++++++++++++++++--
 include/uapi/linux/vfio.h       |  36 +++-
 2 files changed, 337 insertions(+), 14 deletions(-)
Signature · 1 line
2.19.1