Skip to content

RFC iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations

Tina Zhang kvm linux-iommu lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest12 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12iommu/vt-d: Retire the treatment for revoking PASIDs with pending pgfaultsdrivers/iommu/intel/svm.c+0 -70 replies
2/12iommu/vt-d: Remove initialization for dynamically heap-allocated rcu_headdrivers/iommu/intel/svm.c+0 -10 replies
3/12iommu/vt-d: Retire intel_svm_bind_mm()drivers/iommu/intel/svm.c+3 -110 replies
4/12iommu/vt-d: Make dev_to_intel_iommu() helper globaldrivers/iommu/intel/iommu.c drivers/iommu/intel/iommu.h+6 -70 replies
4/12iommu/vt-d: Make dev_to_intel_iommu() helper globaldrivers/iommu/intel/iommu.c drivers/iommu/intel/iommu.h+6 -70 replies
5/12iommu/vt-d: Retire struct intel_svm_devdrivers/iommu/intel/iommu.h drivers/iommu/intel/svm.c+49 -560 replies
6/12iommu: Add mmu_notifier to sva domaininclude/linux/iommu.h+2 -02 replies
7/12iommu/vt-d: Retire struct intel_svmdrivers/iommu/intel/iommu.h drivers/iommu/intel/svm.c+42 -1170 replies
8/12iommu/vt-d: Use RCU for dev_pasids list updates in set/remove_dev_pasid()drivers/iommu/intel/iommu.c+9 -30 replies
9/12iommu/vt-d: Refactor intel_iommu_set_dev_pasid()drivers/iommu/intel/iommu.c drivers/iommu/intel/iommu.h+51 -90 replies
10/12iommu/vt-d: Refactor intel_iommu_remove_dev_pasid()drivers/iommu/intel/iommu.c drivers/iommu/intel/iommu.h drivers/iommu/intel/svm.c+5 -540 replies
11/12iommu/vt-d: Use intel_iommu_set_dev_pasid() for sva domaindrivers/iommu/intel/svm.c+8 -360 replies
12/12iommu/vt-d: Remove superfluous IOMMU IOTLB invalidationsdrivers/iommu/intel/svm.c+27 -290 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [RFC PATCH 00/12] iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations

This series based on "Share sva" patch-set[1], aims to remove superfluous IOMMU IOTLB invalidations in VT-d driver.

In the current VT-d driver, IOMMU IOTLB invalidation commands and device-TLB commands are performed per device, which leads to superfluous IOTLB invalidations. For example, if there are four devices behind a IOMMU are attached to one sva domain (which could be a common case in virtualization scenarios where one virtual IOMMU working for all the virtual devices), four IOTLB invalidation commands and four device-IOTLB invalidation commands will be issued. However, only one IOTLB invalidation command and four device-IOTLB invalidation commands are necessary. Superfluous IOMMU IOTLB invalidations impact run-time performance.

Although the goal could be built straight-forwardly in the current VT-d driver, some refactoring works are considered necessary before landing the one solving the problem of redundant IOTLB invalidations:

1) VT-d driver uses different structures to keep attached device info. For default domain, it uses struct dev_pasids_info and some related fields of struct dmar_domain. For sva domain, it uses struct intel_svm and struct intel_svm_dev. The reason of it is because previously the sva domain is not shared among devices behind different IOMMUs and therefore dmar_domain and its fields cannot be used globally to keep all attached device info. After the patch-set[1] gets acceptance, sva domain is global to the attached devices. Thus, retiring struct intel_svm/intel_svm_dev is the main refactoring work of this patch-set.

2) Most logic of intel_svm_set_dev_pasid() can be covered by intel_iommu_set_dev_pasid(). Refactoring both intel_svm_set_dev_pasid() and intel_iommu_set_dev_pasid() and let the former call the latter for set_dev_pasid operation to avoid duplicating code.

3) Last but not least, struct mmu_notifier is proposed to iommu_domain. This is a change to IOMMU core, which helps to centralize info required by sva to sva domain and therefore can help cleanup the code in IOMMU drivers.

This patchset is on github per-iommu_IOTLB_invalidation branch[2].

[1]: https://lore.kernel.org/linux-iommu/[email protected]/
[2]: https://github.com/TinaZhangZW/linux/tree/per-iommu_IOTLB_invalidation

Tina Zhang (12):
iommu/vt-d: Retire the treatment for revoking PASIDs with pending
pgfaults
iommu/vt-d: Remove initialization for dynamically heap-allocated
rcu_head
iommu/vt-d: Retire intel_svm_bind_mm()
iommu/vt-d: Make dev_to_intel_iommu() helper global iommu/vt-d: Retire struct intel_svm_dev
iommu: Add mmu_notifier to sva domain
iommu/vt-d: Retire struct intel_svm
iommu/vt-d: Use RCU for dev_pasids list updates in
set/remove_dev_pasid()
iommu/vt-d: Refactor intel_iommu_set_dev_pasid() iommu/vt-d: Refactor intel_iommu_remove_dev_pasid() iommu/vt-d: Use intel_iommu_set_dev_pasid() for sva domain iommu/vt-d: Remove superfluous IOMMU IOTLB invalidations

 drivers/iommu/intel/iommu.c |  91 +++++++++----
 drivers/iommu/intel/iommu.h |  30 ++---
 drivers/iommu/intel/svm.c   | 261 ++++++++----------------------------
 include/linux/iommu.h       |   2 +
 4 files changed, 128 insertions(+), 256 deletions(-)
Signature · 1 line
2.39.3