Skip to content

Commit 257ec29

Browse files
TinaZhangZWjoergroedel
authored andcommitted
iommu/vt-d: Allow to use flush-queue when first level is default
Commit 29b3283 ("iommu/vt-d: Do not use flush-queue when caching-mode is on") forced default domains to be strict mode as long as IOMMU caching-mode is flagged. The reason for doing this is that when vIOMMU uses VT-d caching mode to synchronize shadowing page tables, the strict mode shows better performance. However, this optimization is orthogonal to the first-level page table because the Intel VT-d architecture does not define the caching mode of the first-level page table. Refer to VT-d spec, section 6.1, "When the CM field is reported as Set, any software updates to remapping structures other than first-stage mapping (including updates to not- present entries or present entries whose programming resulted in translation faults) requires explicit invalidation of the caches." Exclude the first-level page table from this optimization. Generally using first-stage translation in vIOMMU implies nested translation enabled in the physical IOMMU. In this case the first-stage page table is wholly captured by the guest. The vIOMMU only needs to transfer the cache invalidations on vIOMMU to the physical IOMMU. Forcing the default domain to strict mode will cause more frequent cache invalidations, resulting in performance degradation. In a real performance benchmark test measured by iperf receive, the performance result on Sapphire Rapids 100Gb NIC shows: w/ this fix ~51 Gbits/s, w/o this fix ~39.3 Gbits/s. Theoretically a first-stage IOMMU page table can still be shadowed in absence of the caching mode, e.g. with host write-protecting guest IOMMU page table to synchronize changed PTEs with the physical IOMMU page table. In this case the shadowing overhead is decoupled from emulating IOTLB invalidation then the overhead of the latter part is solely decided by the frequency of IOTLB invalidations. Hence allowing guest default dma domain to be lazy can also benefit the overall performance by reducing the total VM-exit numbers. Fixes: 29b3283 ("iommu/vt-d: Do not use flush-queue when caching-mode is on") Reported-by: Sanjay Kumar <[email protected]> Suggested-by: Sanjay Kumar <[email protected]> Signed-off-by: Tina Zhang <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 194b334 commit 257ec29

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4005,7 +4005,8 @@ int __init intel_iommu_init(void)
40054005
* is likely to be much lower than the overhead of synchronizing
40064006
* the virtual and physical IOMMU page-tables.
40074007
*/
4008-
if (cap_caching_mode(iommu->cap)) {
4008+
if (cap_caching_mode(iommu->cap) &&
4009+
!first_level_by_default(IOMMU_DOMAIN_DMA)) {
40094010
pr_info_once("IOMMU batching disallowed due to virtualization\n");
40104011
iommu_set_dma_strict();
40114012
}

0 commit comments

Comments
 (0)