diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-06-06 03:58:57 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-06-06 05:37:22 -0400 |
commit | a21ca2cac582886a3e95c8bb84ff7c52d4d15e54 (patch) | |
tree | d110005d81e46b1afb3204fbaacc132d0ec946ee /include/linux/perf_counter.h | |
parent | 2f335a02b3c816e77e7df1d15b12e3bbb8f4c8f0 (diff) |
perf_counter: Separate out attr->type from attr->config
Counter type is a frequently used value and we do a lot of
bit juggling by encoding and decoding it from attr->config.
Clean this up by creating a separate attr->type field.
Also clean up the various similarly complex user-space bits
all around counter attribute management.
The net improvement is significant, and it will be easier
to add a new major type (which is what triggered this cleanup).
(This changes the ABI, all tools are adapted.)
(PowerPC build-tested.)
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/perf_counter.h')
-rw-r--r-- | include/linux/perf_counter.h | 65 |
1 files changed, 13 insertions, 52 deletions
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h index 4f9d39ecdc05..f794c69b34c9 100644 --- a/include/linux/perf_counter.h +++ b/include/linux/perf_counter.h | |||
@@ -73,26 +73,6 @@ enum sw_event_ids { | |||
73 | PERF_SW_EVENTS_MAX = 7, | 73 | PERF_SW_EVENTS_MAX = 7, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | #define __PERF_COUNTER_MASK(name) \ | ||
77 | (((1ULL << PERF_COUNTER_##name##_BITS) - 1) << \ | ||
78 | PERF_COUNTER_##name##_SHIFT) | ||
79 | |||
80 | #define PERF_COUNTER_RAW_BITS 1 | ||
81 | #define PERF_COUNTER_RAW_SHIFT 63 | ||
82 | #define PERF_COUNTER_RAW_MASK __PERF_COUNTER_MASK(RAW) | ||
83 | |||
84 | #define PERF_COUNTER_CONFIG_BITS 63 | ||
85 | #define PERF_COUNTER_CONFIG_SHIFT 0 | ||
86 | #define PERF_COUNTER_CONFIG_MASK __PERF_COUNTER_MASK(CONFIG) | ||
87 | |||
88 | #define PERF_COUNTER_TYPE_BITS 7 | ||
89 | #define PERF_COUNTER_TYPE_SHIFT 56 | ||
90 | #define PERF_COUNTER_TYPE_MASK __PERF_COUNTER_MASK(TYPE) | ||
91 | |||
92 | #define PERF_COUNTER_EVENT_BITS 56 | ||
93 | #define PERF_COUNTER_EVENT_SHIFT 0 | ||
94 | #define PERF_COUNTER_EVENT_MASK __PERF_COUNTER_MASK(EVENT) | ||
95 | |||
96 | /* | 76 | /* |
97 | * Bits that can be set in attr.sample_type to request information | 77 | * Bits that can be set in attr.sample_type to request information |
98 | * in the overflow packets. | 78 | * in the overflow packets. |
@@ -125,10 +105,13 @@ enum perf_counter_read_format { | |||
125 | */ | 105 | */ |
126 | struct perf_counter_attr { | 106 | struct perf_counter_attr { |
127 | /* | 107 | /* |
128 | * The MSB of the config word signifies if the rest contains cpu | 108 | * Major type: hardware/software/tracepoint/etc. |
129 | * specific (raw) counter configuration data, if unset, the next | 109 | */ |
130 | * 7 bits are an event type and the rest of the bits are the event | 110 | __u32 type; |
131 | * identifier. | 111 | __u32 __reserved_1; |
112 | |||
113 | /* | ||
114 | * Type specific configuration information. | ||
132 | */ | 115 | */ |
133 | __u64 config; | 116 | __u64 config; |
134 | 117 | ||
@@ -152,12 +135,11 @@ struct perf_counter_attr { | |||
152 | comm : 1, /* include comm data */ | 135 | comm : 1, /* include comm data */ |
153 | freq : 1, /* use freq, not period */ | 136 | freq : 1, /* use freq, not period */ |
154 | 137 | ||
155 | __reserved_1 : 53; | 138 | __reserved_2 : 53; |
156 | 139 | ||
157 | __u32 wakeup_events; /* wakeup every n events */ | 140 | __u32 wakeup_events; /* wakeup every n events */ |
158 | __u32 __reserved_2; | 141 | __u32 __reserved_3; |
159 | 142 | ||
160 | __u64 __reserved_3; | ||
161 | __u64 __reserved_4; | 143 | __u64 __reserved_4; |
162 | }; | 144 | }; |
163 | 145 | ||
@@ -278,8 +260,8 @@ enum perf_event_type { | |||
278 | 260 | ||
279 | /* | 261 | /* |
280 | * struct { | 262 | * struct { |
281 | * struct perf_event_header header; | 263 | * struct perf_event_header header; |
282 | * u32 pid, ppid; | 264 | * u32 pid, ppid; |
283 | * }; | 265 | * }; |
284 | */ | 266 | */ |
285 | PERF_EVENT_FORK = 7, | 267 | PERF_EVENT_FORK = 7, |
@@ -331,27 +313,6 @@ enum perf_event_type { | |||
331 | 313 | ||
332 | struct task_struct; | 314 | struct task_struct; |
333 | 315 | ||
334 | static inline u64 perf_event_raw(struct perf_counter_attr *attr) | ||
335 | { | ||
336 | return attr->config & PERF_COUNTER_RAW_MASK; | ||
337 | } | ||
338 | |||
339 | static inline u64 perf_event_config(struct perf_counter_attr *attr) | ||
340 | { | ||
341 | return attr->config & PERF_COUNTER_CONFIG_MASK; | ||
342 | } | ||
343 | |||
344 | static inline u64 perf_event_type(struct perf_counter_attr *attr) | ||
345 | { | ||
346 | return (attr->config & PERF_COUNTER_TYPE_MASK) >> | ||
347 | PERF_COUNTER_TYPE_SHIFT; | ||
348 | } | ||
349 | |||
350 | static inline u64 perf_event_id(struct perf_counter_attr *attr) | ||
351 | { | ||
352 | return attr->config & PERF_COUNTER_EVENT_MASK; | ||
353 | } | ||
354 | |||
355 | /** | 316 | /** |
356 | * struct hw_perf_counter - performance counter hardware details: | 317 | * struct hw_perf_counter - performance counter hardware details: |
357 | */ | 318 | */ |
@@ -616,8 +577,8 @@ extern int perf_counter_overflow(struct perf_counter *counter, | |||
616 | */ | 577 | */ |
617 | static inline int is_software_counter(struct perf_counter *counter) | 578 | static inline int is_software_counter(struct perf_counter *counter) |
618 | { | 579 | { |
619 | return !perf_event_raw(&counter->attr) && | 580 | return (counter->attr.type != PERF_TYPE_RAW) && |
620 | perf_event_type(&counter->attr) != PERF_TYPE_HARDWARE; | 581 | (counter->attr.type != PERF_TYPE_HARDWARE); |
621 | } | 582 | } |
622 | 583 | ||
623 | extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64); | 584 | extern void perf_swcounter_event(u32, u64, int, struct pt_regs *, u64); |