Lines Matching refs:pmc
9 #define pmc_to_pmu(pmc) (&(pmc)->vcpu->arch.pmu) argument
27 unsigned int (*pmc_perf_hw_id)(struct kvm_pmc *pmc);
29 bool (*pmc_is_enabled)(struct kvm_pmc *pmc);
43 static inline u64 pmc_bitmask(struct kvm_pmc *pmc) in pmc_bitmask() argument
45 struct kvm_pmu *pmu = pmc_to_pmu(pmc); in pmc_bitmask()
47 return pmu->counter_bitmask[pmc->type]; in pmc_bitmask()
50 static inline u64 pmc_read_counter(struct kvm_pmc *pmc) in pmc_read_counter() argument
54 counter = pmc->counter; in pmc_read_counter()
55 if (pmc->perf_event) in pmc_read_counter()
56 counter += perf_event_read_value(pmc->perf_event, in pmc_read_counter()
59 return counter & pmc_bitmask(pmc); in pmc_read_counter()
62 static inline void pmc_release_perf_event(struct kvm_pmc *pmc) in pmc_release_perf_event() argument
64 if (pmc->perf_event) { in pmc_release_perf_event()
65 perf_event_release_kernel(pmc->perf_event); in pmc_release_perf_event()
66 pmc->perf_event = NULL; in pmc_release_perf_event()
67 pmc->current_config = 0; in pmc_release_perf_event()
68 pmc_to_pmu(pmc)->event_count--; in pmc_release_perf_event()
72 static inline void pmc_stop_counter(struct kvm_pmc *pmc) in pmc_stop_counter() argument
74 if (pmc->perf_event) { in pmc_stop_counter()
75 pmc->counter = pmc_read_counter(pmc); in pmc_stop_counter()
76 pmc_release_perf_event(pmc); in pmc_stop_counter()
80 static inline bool pmc_is_gp(struct kvm_pmc *pmc) in pmc_is_gp() argument
82 return pmc->type == KVM_PMC_GP; in pmc_is_gp()
85 static inline bool pmc_is_fixed(struct kvm_pmc *pmc) in pmc_is_fixed() argument
87 return pmc->type == KVM_PMC_FIXED; in pmc_is_fixed()
90 static inline bool pmc_is_enabled(struct kvm_pmc *pmc) in pmc_is_enabled() argument
92 return kvm_x86_ops.pmu_ops->pmc_is_enabled(pmc); in pmc_is_enabled()
133 static inline u64 get_sample_period(struct kvm_pmc *pmc, u64 counter_value) in get_sample_period() argument
135 u64 sample_period = (-counter_value) & pmc_bitmask(pmc); in get_sample_period()
138 sample_period = pmc_bitmask(pmc) + 1; in get_sample_period()
142 void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel);
143 void reprogram_fixed_counter(struct kvm_pmc *pmc, u8 ctrl, int fixed_idx);
148 int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data);