From: Vasant Hegde <vasant.hegde@amd.com>
To: Guanghui Feng <guanghuifeng@linux.alibaba.com>
Cc: iommu@lists.linux.dev, joro@8bytes.org,
linux-kernel@vger.kernel.org, robin.murphy@arm.com,
suravee.suthikulpanit@amd.com, will@kernel.org
Subject: Re: [PATCH v2] iommu/amd: Reuse device data for IRTE cache invalidation
Date: Wed, 2 Dec 2026 15:11:30 +0530 [thread overview]
Message-ID: <a0a9d7e7-99a4-4710-8657-9b773261bcaa@amd.com> (raw)
In-Reply-To: <20261124121518.440906-1-guanghuifeng@linux.alibaba.com>
On 11/24/2026 5:45 PM, Guanghui Feng wrote:
> The DMA alias invalidation path in iommu_flush_irt_and_complete()
> performs a linear search_dev_data() walk on every IRTE update. Nested
> VM entry and exit can switch multiple interrupt routes between guest
> and remapping modes, repeating this lookup for each posted interrupt.
> A reported workload with 4334 device entries shows median lookup
> latencies of 22-33 us per invocation, even when IRT caching is
> disabled and the lookup result is unused.
>
> Save the allocation-time device data in struct amd_ir_data and thread
> it through all IRTE update paths:
>
> - iommu_flush_irt_and_complete() accepts a dev_data parameter. When
> IRT caching is disabled it returns immediately without any lookup.
> When dev_data is NULL (IOAPIC/HPET allocated before PCI enumeration)
> it falls back to search_dev_data() so DMA-alias invalidation still
> works if the device is later probed.
>
> - modify_irte_ga(), modify_irte() and free_irte() accept and forward
> dev_data.
>
> - The amd_irte_ops callbacks (activate, deactivate, set_affinity) are
> extended to carry dev_data so that amd_ir_update_irte() and the
> irq_remapping activate/deactivate domain callbacks pass the cached
> pointer.
>
> - amd_iommu_activate_guest_mode() and deactivate_guest_mode() pass
> ir_data->dev_data directly.
>
> - amd_ir_set_vcpu_affinity() reuses ir_data->dev_data for the vCPU
> affinity capability check. This path is only reachable through
> irq_bypass producers (VFIO-PCI, vhost-vDPA), where device probe
> always precedes IRQ allocation, so dev_data is guaranteed non-NULL.
>
> Device data is retained in the segment list across unplug and reused on
> reprobe, so the cached pointer remains valid throughout the IRQ
> lifetime. The PCI device is still resolved through dev_data->dev at
> flush time so that later device association is observed.
>
> DMA-alias invalidation, command ordering, locking and completion waits
> are preserved when IRT caching is enabled.
>
> Fixes: 5aac28784dca ("iommu/amd: Invalidate IRT cache for DMA aliases")
> Reported-by: Yifei Ge <geyifei@linux.alibaba.com>
> Co-developed-by: hr567 <hr567@linux.alibaba.com>
> Signed-off-by: hr567 <hr567@linux.alibaba.com>
> Signed-off-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
Applied. Thanks!
-Vasant
next prev parent reply other threads:[~2026-12-02 9:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 9:50 [PATCH 0/2] iommu/amd: Optimize IRT cache invalidation for nested VM workloads Guanghui Feng
2026-11-13 9:50 ` [PATCH 1/2] iommu/amd: Skip device lookup when IRT caching is disabled Guanghui Feng
2026-11-23 9:18 ` Vasant Hegde
2026-11-13 9:50 ` [PATCH 2/2] iommu/amd: Reuse device data for IRTE cache invalidation Guanghui Feng
2026-11-23 9:35 ` Vasant Hegde
2026-11-24 12:15 ` [PATCH v2] " Guanghui Feng
2026-11-27 6:16 ` Sairaj Kodilkar
2026-12-02 9:41 ` Vasant Hegde [this message]
2026-11-25 5:34 ` [PATCH 0/2] iommu/amd: Optimize IRT cache invalidation for nested VM workloads Sairaj Kodilkar
2026-12-02 2:31 ` guanghuifeng
2026-12-02 5:22 ` Sairaj Kodilkar
2026-12-02 9:37 ` Vasant Hegde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0a9d7e7-99a4-4710-8657-9b773261bcaa@amd.com \
--to=vasant.hegde@amd.com \
--cc=guanghuifeng@linux.alibaba.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®