aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/perf_counter.h
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-19 15:26:18 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-06 03:30:17 -0400
commitb8e83514b64577b48bfb794fe85fcde40a9343ca (patch)
tree3fd79b41c917f56fe5a5b1f779b892110e0ec909 /include/linux/perf_counter.h
parente077df4f439681e43f0db8255b2d215b342ebdc6 (diff)
perf_counter: revamp syscall input ABI
Impact: modify ABI The hardware/software classification in hw_event->type became a little strained due to the addition of tracepoint tracing. Instead split up the field and provide a type field to explicitly specify the counter type, while using the event_id field to specify which event to use. Raw counters still work as before, only the raw config now goes into raw_event. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Steven Rostedt <rostedt@goodmis.org> Orig-LKML-Reference: <20090319194233.836807573@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r--include/linux/perf_counter.h95
1 files changed, 60 insertions, 35 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 065984c1ff57..8f9394905502 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -21,56 +21,81 @@
21 */ 21 */
22 22
23/* 23/*
24 * Generalized performance counter event types, used by the hw_event.type 24 * hw_event.type
25 * parameter of the sys_perf_counter_open() syscall:
26 */ 25 */
27enum hw_event_types { 26enum perf_event_types {
27 PERF_TYPE_HARDWARE = 0,
28 PERF_TYPE_SOFTWARE = 1,
29 PERF_TYPE_TRACEPOINT = 2,
30
28 /* 31 /*
29 * Common hardware events, generalized by the kernel: 32 * available TYPE space, raw is the max value.
30 */ 33 */
31 PERF_COUNT_CPU_CYCLES = 0,
32 PERF_COUNT_INSTRUCTIONS = 1,
33 PERF_COUNT_CACHE_REFERENCES = 2,
34 PERF_COUNT_CACHE_MISSES = 3,
35 PERF_COUNT_BRANCH_INSTRUCTIONS = 4,
36 PERF_COUNT_BRANCH_MISSES = 5,
37 PERF_COUNT_BUS_CYCLES = 6,
38 34
39 PERF_HW_EVENTS_MAX = 7, 35 PERF_TYPE_RAW = 128,
36};
40 37
38/*
39 * Generalized performance counter event types, used by the hw_event.event_id
40 * parameter of the sys_perf_counter_open() syscall:
41 */
42enum hw_event_ids {
41 /* 43 /*
42 * Special "software" counters provided by the kernel, even if 44 * Common hardware events, generalized by the kernel:
43 * the hardware does not support performance counters. These
44 * counters measure various physical and sw events of the
45 * kernel (and allow the profiling of them as well):
46 */ 45 */
47 PERF_COUNT_CPU_CLOCK = -1, 46 PERF_COUNT_CPU_CYCLES = 0,
48 PERF_COUNT_TASK_CLOCK = -2, 47 PERF_COUNT_INSTRUCTIONS = 1,
49 PERF_COUNT_PAGE_FAULTS = -3, 48 PERF_COUNT_CACHE_REFERENCES = 2,
50 PERF_COUNT_CONTEXT_SWITCHES = -4, 49 PERF_COUNT_CACHE_MISSES = 3,
51 PERF_COUNT_CPU_MIGRATIONS = -5, 50 PERF_COUNT_BRANCH_INSTRUCTIONS = 4,
52 PERF_COUNT_PAGE_FAULTS_MIN = -6, 51 PERF_COUNT_BRANCH_MISSES = 5,
53 PERF_COUNT_PAGE_FAULTS_MAJ = -7, 52 PERF_COUNT_BUS_CYCLES = 6,
54 53
55 PERF_SW_EVENTS_MIN = -8, 54 PERF_HW_EVENTS_MAX = 7,
55};
56 56
57 PERF_TP_EVENTS_MIN = -65536 57/*
58 * Special "software" counters provided by the kernel, even if the hardware
59 * does not support performance counters. These counters measure various
60 * physical and sw events of the kernel (and allow the profiling of them as
61 * well):
62 */
63enum sw_event_ids {
64 PERF_COUNT_CPU_CLOCK = 0,
65 PERF_COUNT_TASK_CLOCK = 1,
66 PERF_COUNT_PAGE_FAULTS = 2,
67 PERF_COUNT_CONTEXT_SWITCHES = 3,
68 PERF_COUNT_CPU_MIGRATIONS = 4,
69 PERF_COUNT_PAGE_FAULTS_MIN = 5,
70 PERF_COUNT_PAGE_FAULTS_MAJ = 6,
71
72 PERF_SW_EVENTS_MAX = 7,
58}; 73};
59 74
60/* 75/*
61 * IRQ-notification data record type: 76 * IRQ-notification data record type:
62 */ 77 */
63enum perf_counter_record_type { 78enum perf_counter_record_type {
64 PERF_RECORD_SIMPLE = 0, 79 PERF_RECORD_SIMPLE = 0,
65 PERF_RECORD_IRQ = 1, 80 PERF_RECORD_IRQ = 1,
66 PERF_RECORD_GROUP = 2, 81 PERF_RECORD_GROUP = 2,
67}; 82};
68 83
69/* 84/*
70 * Hardware event to monitor via a performance monitoring counter: 85 * Hardware event to monitor via a performance monitoring counter:
71 */ 86 */
72struct perf_counter_hw_event { 87struct perf_counter_hw_event {
73 __s64 type; 88 union {
89 struct {
90 __u64 event_id : 56,
91 type : 8;
92 };
93 struct {
94 __u64 raw_event_id : 63,
95 raw_type : 1;
96 };
97 __u64 event_config;
98 };
74 99
75 __u64 irq_period; 100 __u64 irq_period;
76 __u64 record_type; 101 __u64 record_type;
@@ -78,7 +103,6 @@ struct perf_counter_hw_event {
78 103
79 __u64 disabled : 1, /* off by default */ 104 __u64 disabled : 1, /* off by default */
80 nmi : 1, /* NMI sampling */ 105 nmi : 1, /* NMI sampling */
81 raw : 1, /* raw event type */
82 inherit : 1, /* children inherit it */ 106 inherit : 1, /* children inherit it */
83 pinned : 1, /* must always be on PMU */ 107 pinned : 1, /* must always be on PMU */
84 exclusive : 1, /* only group on PMU */ 108 exclusive : 1, /* only group on PMU */
@@ -87,7 +111,7 @@ struct perf_counter_hw_event {
87 exclude_hv : 1, /* ditto hypervisor */ 111 exclude_hv : 1, /* ditto hypervisor */
88 exclude_idle : 1, /* don't count when idle */ 112 exclude_idle : 1, /* don't count when idle */
89 113
90 __reserved_1 : 54; 114 __reserved_1 : 55;
91 115
92 __u32 extra_config_len; 116 __u32 extra_config_len;
93 __u32 __reserved_4; 117 __u32 __reserved_4;
@@ -298,10 +322,11 @@ extern int hw_perf_group_sched_in(struct perf_counter *group_leader,
298 */ 322 */
299static inline int is_software_counter(struct perf_counter *counter) 323static inline int is_software_counter(struct perf_counter *counter)
300{ 324{
301 return !counter->hw_event.raw && counter->hw_event.type < 0; 325 return !counter->hw_event.raw_type &&
326 counter->hw_event.type != PERF_TYPE_HARDWARE;
302} 327}
303 328
304extern void perf_swcounter_event(enum hw_event_types, u64, int, struct pt_regs *); 329extern void perf_swcounter_event(u32, u64, int, struct pt_regs *);
305 330
306#else 331#else
307static inline void 332static inline void
@@ -320,7 +345,7 @@ static inline u64 hw_perf_save_disable(void) { return 0; }
320static inline int perf_counter_task_disable(void) { return -EINVAL; } 345static inline int perf_counter_task_disable(void) { return -EINVAL; }
321static inline int perf_counter_task_enable(void) { return -EINVAL; } 346static inline int perf_counter_task_enable(void) { return -EINVAL; }
322 347
323static inline void perf_swcounter_event(enum hw_event_types event, u64 nr, 348static inline void perf_swcounter_event(u32 event, u64 nr,
324 int nmi, struct pt_regs *regs) { } 349 int nmi, struct pt_regs *regs) { }
325#endif 350#endif
326 351