aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_counter.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-06-06 03:58:57 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-06 05:37:22 -0400
commita21ca2cac582886a3e95c8bb84ff7c52d4d15e54 (patch)
treed110005d81e46b1afb3204fbaacc132d0ec946ee /kernel/perf_counter.c
parent2f335a02b3c816e77e7df1d15b12e3bbb8f4c8f0 (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 'kernel/perf_counter.c')
-rw-r--r--kernel/perf_counter.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 47c92fb927f2..75ae76796df1 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -3091,14 +3091,12 @@ static int perf_swcounter_match(struct perf_counter *counter,
3091 enum perf_event_types type, 3091 enum perf_event_types type,
3092 u32 event, struct pt_regs *regs) 3092 u32 event, struct pt_regs *regs)
3093{ 3093{
3094 u64 event_config;
3095
3096 event_config = ((u64) type << PERF_COUNTER_TYPE_SHIFT) | event;
3097
3098 if (!perf_swcounter_is_counting(counter)) 3094 if (!perf_swcounter_is_counting(counter))
3099 return 0; 3095 return 0;
3100 3096
3101 if (counter->attr.config != event_config) 3097 if (counter->attr.type != type)
3098 return 0;
3099 if (counter->attr.config != event)
3102 return 0; 3100 return 0;
3103 3101
3104 if (regs) { 3102 if (regs) {
@@ -3403,7 +3401,7 @@ static const struct pmu *sw_perf_counter_init(struct perf_counter *counter)
3403 * to be kernel events, and page faults are never hypervisor 3401 * to be kernel events, and page faults are never hypervisor
3404 * events. 3402 * events.
3405 */ 3403 */
3406 switch (perf_event_id(&counter->attr)) { 3404 switch (counter->attr.config) {
3407 case PERF_COUNT_CPU_CLOCK: 3405 case PERF_COUNT_CPU_CLOCK:
3408 pmu = &perf_ops_cpu_clock; 3406 pmu = &perf_ops_cpu_clock;
3409 3407
@@ -3496,12 +3494,12 @@ perf_counter_alloc(struct perf_counter_attr *attr,
3496 if (attr->inherit && (attr->sample_type & PERF_SAMPLE_GROUP)) 3494 if (attr->inherit && (attr->sample_type & PERF_SAMPLE_GROUP))
3497 goto done; 3495 goto done;
3498 3496
3499 if (perf_event_raw(attr)) { 3497 if (attr->type == PERF_TYPE_RAW) {
3500 pmu = hw_perf_counter_init(counter); 3498 pmu = hw_perf_counter_init(counter);
3501 goto done; 3499 goto done;
3502 } 3500 }
3503 3501
3504 switch (perf_event_type(attr)) { 3502 switch (attr->type) {
3505 case PERF_TYPE_HARDWARE: 3503 case PERF_TYPE_HARDWARE:
3506 pmu = hw_perf_counter_init(counter); 3504 pmu = hw_perf_counter_init(counter);
3507 break; 3505 break;