diff options
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r-- | include/linux/perf_counter.h | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index 98f5990be1e1..56099e52970d 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -82,32 +82,37 @@ enum perf_counter_record_type { | |||
82 | PERF_RECORD_GROUP = 2, | 82 | PERF_RECORD_GROUP = 2, |
83 | }; | 83 | }; |
84 | 84 | ||
85 | #define __PERF_COUNTER_MASK(name) \ | ||
86 | (((1ULL << PERF_COUNTER_##name##_BITS) - 1) << \ | ||
87 | PERF_COUNTER_##name##_SHIFT) | ||
88 | |||
89 | #define PERF_COUNTER_RAW_BITS 1 | ||
90 | #define PERF_COUNTER_RAW_SHIFT 63 | ||
91 | #define PERF_COUNTER_RAW_MASK __PERF_COUNTER_MASK(RAW) | ||
92 | |||
93 | #define PERF_COUNTER_CONFIG_BITS 63 | ||
94 | #define PERF_COUNTER_CONFIG_SHIFT 0 | ||
95 | #define PERF_COUNTER_CONFIG_MASK __PERF_COUNTER_MASK(CONFIG) | ||
96 | |||
97 | #define PERF_COUNTER_TYPE_BITS 7 | ||
98 | #define PERF_COUNTER_TYPE_SHIFT 56 | ||
99 | #define PERF_COUNTER_TYPE_MASK __PERF_COUNTER_MASK(TYPE) | ||
100 | |||
101 | #define PERF_COUNTER_EVENT_BITS 56 | ||
102 | #define PERF_COUNTER_EVENT_SHIFT 0 | ||
103 | #define PERF_COUNTER_EVENT_MASK __PERF_COUNTER_MASK(EVENT) | ||
104 | |||
85 | /* | 105 | /* |
86 | * Hardware event to monitor via a performance monitoring counter: | 106 | * Hardware event to monitor via a performance monitoring counter: |
87 | */ | 107 | */ |
88 | struct perf_counter_hw_event { | 108 | struct perf_counter_hw_event { |
89 | union { | 109 | /* |
90 | #ifndef __BIG_ENDIAN_BITFIELD | 110 | * The MSB of the config word signifies if the rest contains cpu |
91 | struct { | 111 | * specific (raw) counter configuration data, if unset, the next |
92 | __u64 event_id : 56, | 112 | * 7 bits are an event type and the rest of the bits are the event |
93 | type : 8; | 113 | * identifier. |
94 | }; | 114 | */ |
95 | struct { | 115 | __u64 config; |
96 | __u64 raw_event_id : 63, | ||
97 | raw_type : 1; | ||
98 | }; | ||
99 | #else | ||
100 | struct { | ||
101 | __u64 type : 8, | ||
102 | event_id : 56; | ||
103 | }; | ||
104 | struct { | ||
105 | __u64 raw_type : 1, | ||
106 | raw_event_id : 63; | ||
107 | }; | ||
108 | #endif /* __BIT_ENDIAN_BITFIELD */ | ||
109 | __u64 event_config; | ||
110 | }; | ||
111 | 116 | ||
112 | __u64 irq_period; | 117 | __u64 irq_period; |
113 | __u64 record_type; | 118 | __u64 record_type; |
@@ -157,6 +162,27 @@ struct perf_counter_hw_event { | |||
157 | 162 | ||
158 | struct task_struct; | 163 | struct task_struct; |
159 | 164 | ||
165 | static inline u64 perf_event_raw(struct perf_counter_hw_event *hw_event) | ||
166 | { | ||
167 | return hw_event->config & PERF_COUNTER_RAW_MASK; | ||
168 | } | ||
169 | |||
170 | static inline u64 perf_event_config(struct perf_counter_hw_event *hw_event) | ||
171 | { | ||
172 | return hw_event->config & PERF_COUNTER_CONFIG_MASK; | ||
173 | } | ||
174 | |||
175 | static inline u64 perf_event_type(struct perf_counter_hw_event *hw_event) | ||
176 | { | ||
177 | return (hw_event->config & PERF_COUNTER_TYPE_MASK) >> | ||
178 | PERF_COUNTER_TYPE_SHIFT; | ||
179 | } | ||
180 | |||
181 | static inline u64 perf_event_id(struct perf_counter_hw_event *hw_event) | ||
182 | { | ||
183 | return hw_event->config & PERF_COUNTER_EVENT_MASK; | ||
184 | } | ||
185 | |||
160 | /** | 186 | /** |
161 | * struct hw_perf_counter - performance counter hardware details: | 187 | * struct hw_perf_counter - performance counter hardware details: |
162 | */ | 188 | */ |
@@ -336,8 +362,8 @@ extern void perf_counter_output(struct perf_counter *counter, | |||
336 | */ | 362 | */ |
337 | static inline int is_software_counter(struct perf_counter *counter) | 363 | static inline int is_software_counter(struct perf_counter *counter) |
338 | { | 364 | { |
339 | return !counter->hw_event.raw_type && | 365 | return !perf_event_raw(&counter->hw_event) && |
340 | counter->hw_event.type != PERF_TYPE_HARDWARE; | 366 | perf_event_type(&counter->hw_event) != PERF_TYPE_HARDWARE; |
341 | } | 367 | } |
342 | 368 | ||
343 | extern void perf_swcounter_event(u32, u64, int, struct pt_regs *); | 369 | extern void perf_swcounter_event(u32, u64, int, struct pt_regs *); |