Lines Matching full:pmc
9 #define pmc_to_pmu(pmc) (&(pmc)->vcpu->arch.pmu) argument
30 bool (*pmc_is_enabled)(struct kvm_pmc *pmc);
46 static inline u64 pmc_bitmask(struct kvm_pmc *pmc) in pmc_bitmask() argument
48 struct kvm_pmu *pmu = pmc_to_pmu(pmc); in pmc_bitmask()
50 return pmu->counter_bitmask[pmc->type]; in pmc_bitmask()
53 static inline u64 pmc_read_counter(struct kvm_pmc *pmc) in pmc_read_counter() argument
57 counter = pmc->counter; in pmc_read_counter()
58 if (pmc->perf_event && !pmc->is_paused) in pmc_read_counter()
59 counter += perf_event_read_value(pmc->perf_event, in pmc_read_counter()
62 return counter & pmc_bitmask(pmc); in pmc_read_counter()
65 static inline void pmc_release_perf_event(struct kvm_pmc *pmc) in pmc_release_perf_event() argument
67 if (pmc->perf_event) { in pmc_release_perf_event()
68 perf_event_release_kernel(pmc->perf_event); in pmc_release_perf_event()
69 pmc->perf_event = NULL; in pmc_release_perf_event()
70 pmc->current_config = 0; in pmc_release_perf_event()
71 pmc_to_pmu(pmc)->event_count--; in pmc_release_perf_event()
75 static inline void pmc_stop_counter(struct kvm_pmc *pmc) in pmc_stop_counter() argument
77 if (pmc->perf_event) { in pmc_stop_counter()
78 pmc->counter = pmc_read_counter(pmc); in pmc_stop_counter()
79 pmc_release_perf_event(pmc); in pmc_stop_counter()
83 static inline bool pmc_is_gp(struct kvm_pmc *pmc) in pmc_is_gp() argument
85 return pmc->type == KVM_PMC_GP; in pmc_is_gp()
88 static inline bool pmc_is_fixed(struct kvm_pmc *pmc) in pmc_is_fixed() argument
90 return pmc->type == KVM_PMC_FIXED; in pmc_is_fixed()
93 static inline bool pmc_is_enabled(struct kvm_pmc *pmc) in pmc_is_enabled() argument
95 return kvm_x86_ops.pmu_ops->pmc_is_enabled(pmc); in pmc_is_enabled()
104 /* returns general purpose PMC with the specified MSR. Note that it can be
121 /* returns fixed PMC with the specified MSR */
136 static inline u64 get_sample_period(struct kvm_pmc *pmc, u64 counter_value) in get_sample_period() argument
138 u64 sample_period = (-counter_value) & pmc_bitmask(pmc); in get_sample_period()
141 sample_period = pmc_bitmask(pmc) + 1; in get_sample_period()
145 void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel);
146 void reprogram_fixed_counter(struct kvm_pmc *pmc, u8 ctrl, int fixed_idx);
151 int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);