From: Sairaj Kodilkar <sarunkod@amd.com>
To: Guanghui Feng <guanghuifeng@linux.alibaba.com>, <joro@8bytes.org>,
<vasant.hegde@amd.com>, <suravee.suthikulpanit@amd.com>,
<will@kernel.org>, <robin.murphy@arm.com>
Cc: <iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 0/2] iommu/amd: Optimize IRT cache invalidation for nested VM workloads
Date: Wed, 25 Nov 2026 11:04:01 +0530 [thread overview]
Message-ID: <9bb63df8-29b5-4b0c-9758-3fbbdb61dd06@amd.com> (raw)
In-Reply-To: <20261113095017.1835921-1-guanghuifeng@linux.alibaba.com>
On 11/13/2026 3:20 PM, Guanghui Feng wrote:
> This series optimizes the AMD IOMMU interrupt remapping table (IRT)
> cache invalidation path for nested virtualization workloads.
>
> When IOMMU AVIC is enabled, every nested VM entry/exit that switches
> interrupt routes between guest and remapping modes calls into
> iommu_flush_irt_and_complete(). A reported workload with 4334 device
> entries shows median lookup latencies of 22-33 us per invocation due
> to a linear search_dev_data() walk, even when IRT caching is disabled
> and the lookup result is unused.
>
> Patch 1 moves the device lookup after the irtcachedis_enabled early
> return, eliminating the unnecessary walk when IRT caching is off.
>
> Patch 2 caches the device data pointer (resolved at IRQ allocation
> time) in struct amd_ir_data and threads it through all IRTE update
> paths: guest-mode toggle, affinity change, IRQ enable/disable, and
> IRTE free. The amd_irte_ops interface is extended to carry the
> pointer, eliminating all search_dev_data() calls at runtime.
>
> Both patches preserve DMA-alias invalidation, command ordering,
> locking, and completion-wait semantics when IRT caching is enabled.
>
> Guanghui Feng (2):
> iommu/amd: Skip device lookup when IRT caching is disabled
> iommu/amd: Reuse device data for IRTE cache invalidation
>
> drivers/iommu/amd/amd_iommu_types.h | 10 ++--
> drivers/iommu/amd/iommu.c | 73 ++++++++++++++++-------------
> 2 files changed, 48 insertions(+), 35 deletions(-)
>
Hi Guanghui,
Thanks for the patches. I ran a few tests to measure their impact.
Setup: 12 VMs, each with 32 vCPUs and one passthrough NVMe device. Each
VM runs a small nested (L2) guest that executes CPUID in a loop, which
toggles AVIC for every nested VMRUN/#VMEXIT.
At a 1:1 pCPU:vCPU ratio, averaged across the 12 VMs:
search_dev_data() lookup: 373.4 ns
iommu_flush_irt_and_complete(): 172546.1 ns (including the
COMPLETION_WAIT)
So the lookup is about 0.2% of the flush path. The completion wait is
the main bottleneck here, and the overall gain from this change is
minimal for this path.
The change is still valid, though. It removes a linear walk of the
dev_data list and the may help other places in the driver that call
search_dev_data().
Tested-by: Sairaj Kodilkar <sarunkod@amd.com>
Thanks,
Sairaj
prev parent reply other threads:[~2026-11-25 5:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 9:50 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-25 5:34 ` Sairaj Kodilkar [this message]
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=9bb63df8-29b5-4b0c-9758-3fbbdb61dd06@amd.com \
--to=sarunkod@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=vasant.hegde@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®