[PATCH v5 44/44] KVM: x86/pmu: Elide WRMSRs when loading guest PMCs if values already match

Manali Shukla manali.shukla at amd.com
Thu Nov 13 22:19:30 PST 2025


On 8/7/2025 1:27 AM, Sean Christopherson wrote:
> When loading a mediated PMU state, elide the WRMSRs to load PMCs with the
> guest's value if the value in hardware already matches the guest's value.
> For the relatively common case where neither the guest nor the host is
> actively using the PMU, i.e. when all/many counters are '0', eliding the
> WRMSRs reduces the latency of handling VM-Exit by a measurable amount
> (WRMSR is significantly more expensive than RDPMC).
> 
> As measured by KVM-Unit-Tests' CPUID VM-Exit testcase, this provides a
> a ~25% reduction in latency (4k => 3k cycles) on Intel Emerald Rapids,
> and a ~13% reduction (6.2k => 5.3k cycles) on AMD Turing.

Nit. s/AMD Turing/AMD Turin

-Manali
> 
> Signed-off-by: Sean Christopherson <seanjc at google.com>



More information about the linux-arm-kernel mailing list