Lines Matching refs:pmc
9 #define pmc_to_pmu(pmc) (&(pmc)->vcpu->arch.pmu)
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)
45 struct kvm_pmu *pmu = pmc_to_pmu(pmc);
47 return pmu->counter_bitmask[pmc->type];
50 static inline u64 pmc_read_counter(struct kvm_pmc *pmc)
54 counter = pmc->counter;
55 if (pmc->perf_event)
56 counter += perf_event_read_value(pmc->perf_event,
59 return counter & pmc_bitmask(pmc);
62 static inline void pmc_release_perf_event(struct kvm_pmc *pmc)
64 if (pmc->perf_event) {
65 perf_event_release_kernel(pmc->perf_event);
66 pmc->perf_event = NULL;
67 pmc->current_config = 0;
68 pmc_to_pmu(pmc)->event_count--;
72 static inline void pmc_stop_counter(struct kvm_pmc *pmc)
74 if (pmc->perf_event) {
75 pmc->counter = pmc_read_counter(pmc);
76 pmc_release_perf_event(pmc);
80 static inline bool pmc_is_gp(struct kvm_pmc *pmc)
82 return pmc->type == KVM_PMC_GP;
85 static inline bool pmc_is_fixed(struct kvm_pmc *pmc)
87 return pmc->type == KVM_PMC_FIXED;
90 static inline bool pmc_is_enabled(struct kvm_pmc *pmc)
92 return kvm_x86_ops.pmu_ops->pmc_is_enabled(pmc);
133 static inline u64 get_sample_period(struct kvm_pmc *pmc, u64 counter_value)
135 u64 sample_period = (-counter_value) & pmc_bitmask(pmc);
138 sample_period = pmc_bitmask(pmc) + 1;
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);