Lines Matching full:pmc
9 #define pmc_to_pmu(pmc) (&(pmc)->vcpu->arch.pmu) argument
28 bool (*hw_event_available)(struct kvm_pmc *pmc);
29 bool (*pmc_is_enabled)(struct kvm_pmc *pmc);
47 static inline u64 pmc_bitmask(struct kvm_pmc *pmc) in pmc_bitmask() argument
49 struct kvm_pmu *pmu = pmc_to_pmu(pmc); in pmc_bitmask()
51 return pmu->counter_bitmask[pmc->type]; in pmc_bitmask()
54 static inline u64 pmc_read_counter(struct kvm_pmc *pmc) in pmc_read_counter() argument
58 counter = pmc->counter; in pmc_read_counter()
59 if (pmc->perf_event && !pmc->is_paused) in pmc_read_counter()
60 counter += perf_event_read_value(pmc->perf_event, in pmc_read_counter()
63 return counter & pmc_bitmask(pmc); in pmc_read_counter()
66 static inline void pmc_release_perf_event(struct kvm_pmc *pmc) in pmc_release_perf_event() argument
68 if (pmc->perf_event) { in pmc_release_perf_event()
69 perf_event_release_kernel(pmc->perf_event); in pmc_release_perf_event()
70 pmc->perf_event = NULL; in pmc_release_perf_event()
71 pmc->current_config = 0; in pmc_release_perf_event()
72 pmc_to_pmu(pmc)->event_count--; in pmc_release_perf_event()
76 static inline void pmc_stop_counter(struct kvm_pmc *pmc) in pmc_stop_counter() argument
78 if (pmc->perf_event) { in pmc_stop_counter()
79 pmc->counter = pmc_read_counter(pmc); in pmc_stop_counter()
80 pmc_release_perf_event(pmc); in pmc_stop_counter()
84 static inline bool pmc_is_gp(struct kvm_pmc *pmc) in pmc_is_gp() argument
86 return pmc->type == KVM_PMC_GP; in pmc_is_gp()
89 static inline bool pmc_is_fixed(struct kvm_pmc *pmc) in pmc_is_fixed() argument
91 return pmc->type == KVM_PMC_FIXED; in pmc_is_fixed()
100 /* returns general purpose PMC with the specified MSR. Note that it can be
117 /* returns fixed PMC with the specified MSR */
132 static inline u64 get_sample_period(struct kvm_pmc *pmc, u64 counter_value) in get_sample_period() argument
134 u64 sample_period = (-counter_value) & pmc_bitmask(pmc); in get_sample_period()
137 sample_period = pmc_bitmask(pmc) + 1; in get_sample_period()
141 static inline void pmc_update_sample_period(struct kvm_pmc *pmc) in pmc_update_sample_period() argument
143 if (!pmc->perf_event || pmc->is_paused) in pmc_update_sample_period()
146 perf_event_period(pmc->perf_event, in pmc_update_sample_period()
147 get_sample_period(pmc, pmc->counter)); in pmc_update_sample_period()
150 static inline bool pmc_speculative_in_use(struct kvm_pmc *pmc) in pmc_speculative_in_use() argument
152 struct kvm_pmu *pmu = pmc_to_pmu(pmc); in pmc_speculative_in_use()
154 if (pmc_is_fixed(pmc)) in pmc_speculative_in_use()
156 pmc->idx - INTEL_PMC_IDX_FIXED) & 0x3; in pmc_speculative_in_use()
158 return pmc->eventsel & ARCH_PERFMON_EVENTSEL_ENABLE; in pmc_speculative_in_use()
186 void reprogram_counter(struct kvm_pmc *pmc);
190 int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);