On Sat, Nov 04, 2023, Jim Mattson wrote: > On Fri, Nov 3, 2023 at 5:03 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote: > > static void guest_test_arch_event(uint8_t idx) > > { > > const struct { > > struct kvm_x86_pmu_feature gp_event; > > + struct kvm_x86_pmu_feature fixed_event; > > } intel_event_to_feature[] = { > > - [INTEL_ARCH_CPU_CYCLES] = { X86_PMU_FEATURE_CPU_CYCLES }, > > - [INTEL_ARCH_INSTRUCTIONS_RETIRED] = { X86_PMU_FEATURE_INSNS_RETIRED }, > > - [INTEL_ARCH_REFERENCE_CYCLES] = { X86_PMU_FEATURE_REFERENCE_CYCLES }, > > - [INTEL_ARCH_LLC_REFERENCES] = { X86_PMU_FEATURE_LLC_REFERENCES }, > > - [INTEL_ARCH_LLC_MISSES] = { X86_PMU_FEATURE_LLC_MISSES }, > > - [INTEL_ARCH_BRANCHES_RETIRED] = { X86_PMU_FEATURE_BRANCH_INSNS_RETIRED }, > > - [INTEL_ARCH_BRANCHES_MISPREDICTED] = { X86_PMU_FEATURE_BRANCHES_MISPREDICTED }, > > + [INTEL_ARCH_CPU_CYCLES] = { X86_PMU_FEATURE_CPU_CYCLES, X86_PMU_FEATURE_CPU_CYCLES_FIXED }, > > + [INTEL_ARCH_INSTRUCTIONS_RETIRED] = { X86_PMU_FEATURE_INSNS_RETIRED, X86_PMU_FEATURE_INSNS_RETIRED_FIXED }, > > + /* > > + * Note, the fixed counter for reference cycles is NOT the same > > + * as the general purpose architectural event (because the GP > > + * event is garbage). The fixed counter explicitly counts at > > + * the same frequency as the TSC, whereas the GP event counts > > + * at a fixed, but uarch specific, frequency. Bundle them here > > + * for simplicity. > > + */ > > Implementation-specific is not necessarily garbage, though it would be > nice if there was a way to query the frequency rather than calibrating > against another clock. Heh, I'll drop the editorial commentry, though I still think an architectural event with implementation-specific behavior is garbage :-)