On 10/8/2023 1:45 pm, Xiong Zhang wrote:
+1. Overview +=========== + +KVM has supported PMU virtualization on x86 for many years and provides
"logical core level PMU virtualization"
+MSR based Arch PMU interface to the guest. The major features include
Drop the "MSR based Arch PMU interface" statement, considering RDPMC.
+Arch PMU v2, LBR and PEBS. Users have the same operation to profile
include (Arch for Intel) pmu versions up to 2, basic counters, Intel LBR and PEBS, etc.
+performance in guest and host.
Any pmu profiler that works on host based on core pmu (e.g. Linux perl tool) can be expected to work on guest. On linux host and guest, the perf subsystem manages pmu hardware resources.
+KVM is a normal perf subsystem user as other perf subsystem users. When
, but in the kernel space like nmi_watchdog and some ebpf programs that use pmu.
+the guest access vPMU MSRs, KVM traps it and creates a perf event for it.
This is inaccurate. KVM emulates the different guest's PMU capabilities as accurately as possible via creating the appropriate perf_event(s) in the kernel space to occupy the corresponding PMU resources from the host.
+This perf event takes part in perf scheduler to request PMU resources +and let the guest use these resources.
From the host perf-core perspective, these KVM-created perf events take part in perf scheduler, just like any other perf_events.
+ +This document describes the X86 PMU virtualization architecture design
Intel PMU only or add more AMD stuff.
+and opens. It is organized as follows: Next section describes more +details of Linux perf scheduler as it takes a key role in vPMU +implementation and allocates PMU resources for guest usage. Then Arch +PMU virtualization and LBR virtualization are introduced, each feature +has sections to introduce implementation overview, the expectation and +gaps when host and guest perf events coexist.