Re: [PATCH 2/2] iommu/amd: Reuse device data for IRTE cache invalidation

From: Vasant Hegde

Date: Mon Nov 23 2026 - 04:35:59 EST




On 11/13/2026 3:20 PM, Guanghui Feng wrote:
> Switching an interrupt route between guest and remapping modes, changing
> IRQ affinity, and enabling or disabling an IRTE all perform a linear
> device lookup to invalidate the IRT cache for DMA aliases. Nested VM
> entry and exit can repeat this for every posted interrupt route.
> A reported workload with 4334 device entries shows median lookup
> latencies of 22-33 us per invocation.
>
> Save the allocation-time device data in struct amd_ir_data and thread it
> through all IRTE update paths:
>
> - modify_irte_ga() and modify_irte() accept a dev_data parameter and
> pass it to iommu_flush_irt_and_complete().
>
> - The amd_irte_ops callbacks (activate, deactivate, set_affinity) are
> extended to carry dev_data, so amd_ir_update_irte() and the
> irq_remapping activate/deactivate chip callbacks pass the cached
> pointer.
>
> - amd_iommu_activate_guest_mode() and deactivate_guest_mode() pass
> ir_data->dev_data directly.
>
> - free_irte() receives dev_data from irq_remapping_free().
>
> - amd_ir_set_vcpu_affinity() reuses ir_data->dev_data for the vCPU
> affinity capability check.
>
> This eliminates all search_dev_data() list walks from IRTE update
> paths. For non-PCI interrupt sources (IOAPIC, HPET) whose dev_data is
> NULL from allocation, iommu_flush_irt_and_complete() skips the DMA
> alias walk and invalidates only the single devid, which is correct
> because these sources have no DMA aliases.

In iommu_flush_irt_and_complete() may be fall back to search_dev_data if
dev_data is NULL?


Its fine for set_vcpu_affinity() path as we know it gets called only after probe
is complete.

Otherwise patch look.

-Vasant