Skip to content

Commit b3d9468

Browse files
Gleb NatapovIngo Molnar
authored andcommitted
perf, x86: Expose perf capability to other modules
KVM needs to know perf capability to decide which PMU it can expose to a guest. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1320929850-10480-8-git-send-email-gleb@redhat.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent c1d6f42 commit b3d9468

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎arch/x86/include/asm/perf_event.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ union cpuid10_edx {
9595
unsigned int full;
9696
};
9797

98+
struct x86_pmu_capability {
99+
int version;
100+
int num_counters_gp;
101+
int num_counters_fixed;
102+
int bit_width_gp;
103+
int bit_width_fixed;
104+
unsigned int events_mask;
105+
int events_mask_len;
106+
};
98107

99108
/*
100109
* Fixed-purpose performance events:
@@ -216,13 +225,19 @@ struct perf_guest_switch_msr {
216225
};
217226

218227
extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
228+
extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap);
219229
#else
220230
static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
221231
{
222232
*nr = 0;
223233
return NULL;
224234
}
225235

236+
static inline void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
237+
{
238+
memset(cap, 0, sizeof(*cap));
239+
}
240+
226241
static inline void perf_events_lapic_init(void) { }
227242
#endif
228243

‎arch/x86/kernel/cpu/perf_event.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,3 +1696,15 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
16961696

16971697
return misc;
16981698
}
1699+
1700+
void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
1701+
{
1702+
cap->version = x86_pmu.version;
1703+
cap->num_counters_gp = x86_pmu.num_counters;
1704+
cap->num_counters_fixed = x86_pmu.num_counters_fixed;
1705+
cap->bit_width_gp = x86_pmu.cntval_bits;
1706+
cap->bit_width_fixed = x86_pmu.cntval_bits;
1707+
cap->events_mask = (unsigned int)x86_pmu.events_maskl;
1708+
cap->events_mask_len = x86_pmu.events_mask_len;
1709+
}
1710+
EXPORT_SYMBOL_GPL(perf_get_x86_pmu_capability);

0 commit comments

Comments
 (0)