kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PMU virtualization and AMD erratum 1292
@ 2022-01-14 20:02 Jim Mattson
  2022-01-17  4:26 ` Like Xu
  0 siblings, 1 reply; 8+ messages in thread
From: Jim Mattson @ 2022-01-14 20:02 UTC (permalink / raw)
  To: kvm list; +Cc: Like Xu, Paolo Bonzini, Stephane Eranian

From AMD erratum 1292:

The processor may experience sampling inaccuracies that cause the
following performance counters to overcount retire-based events.
 • PMCx0C0 [Retired Instructions]
 • PMCx0C1 [Retired Uops]
 • PMCx0C2 [Retired Branch Instructions]
 • PMCx0C3 [Retired Branch Instructions Mispredicted]
 • PMCx0C4 [Retired Taken Branch Instructions]
 • PMCx0C5 [Retired Taken Branch Instructions Mispredicted]
 • PMCx0C8 [Retired Near Returns]
 • PMCx0C9 [Retired Near Returns Mispredicted]
 • PMCx0CA [Retired Indirect Branch Instructions Mispredicted]
• PMCx0CC [Retired Indirect Branch Instructions]
 • PMCx0D1 [Retired Conditional Branch Instructions]
 • PMCx1C7 [Retired Mispredicted Branch Instructions due to Direction Mismatch]
 • PMCx1D0 [Retired Fused Branch Instructions]

The recommended workaround is:

To count the non-FP affected PMC events correctly:
 • Use Core::X86::Msr::PERF_CTL2 to count the events, and
 • Program Core::X86::Msr::PERF_CTL2[43] to 1b, and
 • Program Core::X86::Msr::PERF_CTL2[20] to 0b.

It's unfortunate that kvm's PMU virtualization completely circumvents
any attempt to employ the recommended workaround. Admittedly, bit 43
is "reserved," and it would be foolish for a hypervisor to let a guest
set a reserved bit in a host MSR. But, even the first recommendation
is impossible under KVM, because the host's perf subsystem actually
decides which hardware counter is going to be used, regardless of what
the guest asks for.

Am I the only one bothered by this?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-19  4:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 20:02 PMU virtualization and AMD erratum 1292 Jim Mattson
2022-01-17  4:26 ` Like Xu
2022-01-17 20:57   ` Jim Mattson
2022-01-18  4:08     ` Jim Mattson
2022-01-18  6:25       ` Like Xu
2022-01-18 18:22         ` Jim Mattson
2022-01-19  3:54           ` Like Xu
2022-01-19  4:36             ` Ananth Narayan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).