@@ -10,6 +10,7 @@ void pmu_init(void)
pmu.perf_cap = rdmsr(MSR_IA32_PERF_CAPABILITIES);
pmu.msr_gp_counter_base = MSR_IA32_PERFCTR0;
pmu.msr_gp_event_select_base = MSR_P6_EVNTSEL0;
+ pmu.nr_gp_counters = (cpuid_10.a >> 8) & 0xff;
if (this_cpu_support_perf_status()) {
pmu.msr_global_status = MSR_CORE_PERF_GLOBAL_STATUS;
pmu.msr_global_ctl = MSR_CORE_PERF_GLOBAL_CTRL;
@@ -54,6 +54,7 @@ struct pmu_caps {
u32 msr_global_status;
u32 msr_global_ctl;
u32 msr_global_status_clr;
+ unsigned int nr_gp_counters;
};
extern struct cpuid cpuid_10;
@@ -123,7 +124,13 @@ static inline bool this_cpu_support_perf_status(void)
static inline u8 pmu_nr_gp_counters(void)
{
- return (cpuid_10.a >> 8) & 0xff;
+ return pmu.nr_gp_counters;
+}
+
+static inline void set_nr_gp_counters(u8 new_num)
+{
+ if (new_num < pmu_nr_gp_counters())
+ pmu.nr_gp_counters = new_num;
}
static inline u8 pmu_gp_counter_width(void)