3 #include <linux/perf_event.h>
4 #include <linux/types.h>
6 #include <asm/hardirq.h>
10 static const u64 knc_perfmon_event_map[] =
33 [
C(RESULT_MISS) ] = 0x0003,
36 [
C(RESULT_ACCESS) ] = 0x0001,
37 [
C(RESULT_MISS) ] = 0x0004,
39 [
C(OP_PREFETCH) ] = {
40 [
C(RESULT_ACCESS) ] = 0x0011,
41 [
C(RESULT_MISS) ] = 0x001c,
46 [
C(RESULT_ACCESS) ] = 0x000c,
47 [
C(RESULT_MISS) ] = 0x000e,
50 [
C(RESULT_ACCESS) ] = -1,
51 [
C(RESULT_MISS) ] = -1,
53 [
C(OP_PREFETCH) ] = {
54 [
C(RESULT_ACCESS) ] = 0x0,
55 [
C(RESULT_MISS) ] = 0x0,
60 [
C(RESULT_ACCESS) ] = 0,
61 [
C(RESULT_MISS) ] = 0x10cb,
64 [
C(RESULT_ACCESS) ] = 0x10cc,
65 [
C(RESULT_MISS) ] = 0,
67 [
C(OP_PREFETCH) ] = {
68 [
C(RESULT_ACCESS) ] = 0x10fc,
69 [
C(RESULT_MISS) ] = 0x10fe,
77 [
C(RESULT_MISS) ] = 0x0002,
80 [
C(RESULT_ACCESS) ] = 0x0001,
81 [
C(RESULT_MISS) ] = 0x0002,
83 [
C(OP_PREFETCH) ] = {
84 [
C(RESULT_ACCESS) ] = 0x0,
85 [
C(RESULT_MISS) ] = 0x0,
90 [
C(RESULT_ACCESS) ] = 0x000c,
91 [
C(RESULT_MISS) ] = 0x000d,
94 [
C(RESULT_ACCESS) ] = -1,
95 [
C(RESULT_MISS) ] = -1,
97 [
C(OP_PREFETCH) ] = {
98 [
C(RESULT_ACCESS) ] = -1,
99 [
C(RESULT_MISS) ] = -1,
104 [
C(RESULT_ACCESS) ] = 0x0012,
105 [
C(RESULT_MISS) ] = 0x002b,
108 [
C(RESULT_ACCESS) ] = -1,
109 [
C(RESULT_MISS) ] = -1,
111 [
C(OP_PREFETCH) ] = {
112 [
C(RESULT_ACCESS) ] = -1,
113 [
C(RESULT_MISS) ] = -1,
119 static u64 knc_pmu_event_map(
int hw_event)
121 return knc_perfmon_event_map[hw_event];
150 #define MSR_KNC_IA32_PERF_GLOBAL_STATUS 0x0000002d
151 #define MSR_KNC_IA32_PERF_GLOBAL_OVF_CONTROL 0x0000002e
152 #define MSR_KNC_IA32_PERF_GLOBAL_CTRL 0x0000002f
154 #define KNC_ENABLE_COUNTER0 0x00000001
155 #define KNC_ENABLE_COUNTER1 0x00000002
157 static void knc_pmu_disable_all(
void)
166 static void knc_pmu_enable_all(
int added)
184 (
void)wrmsrl_safe(hwc->config_base + hwc->idx, val);
187 static void knc_pmu_enable_event(
struct perf_event *event)
195 (
void)wrmsrl_safe(hwc->config_base + hwc->idx, val);
198 static inline u64 knc_pmu_get_status(
void)
207 static inline void knc_pmu_ack_status(
u64 ack)
212 static int knc_pmu_handle_irq(
struct pt_regs *
regs)
214 struct perf_sample_data
data;
222 knc_pmu_disable_all();
224 status = knc_pmu_get_status();
226 knc_pmu_enable_all(0);
232 knc_pmu_ack_status(status);
252 perf_sample_data_init(&
data, 0, event->hw.last_period);
261 status = knc_pmu_get_status();
266 knc_pmu_enable_all(0);
278 static struct attribute *intel_knc_formats_attr[] = {
279 &format_attr_event.attr,
280 &format_attr_umask.attr,
281 &format_attr_edge.attr,
282 &format_attr_inv.attr,
283 &format_attr_cmask.attr,
289 .handle_irq = knc_pmu_handle_irq,
290 .disable_all = knc_pmu_disable_all,
291 .enable_all = knc_pmu_enable_all,
292 .enable = knc_pmu_enable_event,
293 .disable = knc_pmu_disable_event,
298 .event_map = knc_pmu_event_map,
299 .max_events =
ARRAY_SIZE(knc_perfmon_event_map),
301 .max_period = (1ULL << 39) - 1,
307 .event_constraints = knc_event_constraints,
308 .format_attrs = intel_knc_formats_attr,