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 /arch | |
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 'arch')
-rw-r--r-- | arch/powerpc/kernel/perf_counter.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_counter.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/arch/powerpc/kernel/perf_counter.c b/arch/powerpc/kernel/perf_counter.c index 232b00a36f79..4786ad9a2887 100644 --- a/arch/powerpc/kernel/perf_counter.c +++ b/arch/powerpc/kernel/perf_counter.c | |||
@@ -867,13 +867,13 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter) | |||
867 | 867 | ||
868 | if (!ppmu) | 868 | if (!ppmu) |
869 | return ERR_PTR(-ENXIO); | 869 | return ERR_PTR(-ENXIO); |
870 | if (!perf_event_raw(&counter->attr)) { | 870 | if (counter->attr.type != PERF_TYPE_RAW) { |
871 | ev = perf_event_id(&counter->attr); | 871 | ev = counter->attr.config; |
872 | if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0) | 872 | if (ev >= ppmu->n_generic || ppmu->generic_events[ev] == 0) |
873 | return ERR_PTR(-EOPNOTSUPP); | 873 | return ERR_PTR(-EOPNOTSUPP); |
874 | ev = ppmu->generic_events[ev]; | 874 | ev = ppmu->generic_events[ev]; |
875 | } else { | 875 | } else { |
876 | ev = perf_event_config(&counter->attr); | 876 | ev = counter->attr.config; |
877 | } | 877 | } |
878 | counter->hw.config_base = ev; | 878 | counter->hw.config_base = ev; |
879 | counter->hw.idx = 0; | 879 | counter->hw.idx = 0; |
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c index 8f53f3a7da29..430e048f2854 100644 --- a/arch/x86/kernel/cpu/perf_counter.c +++ b/arch/x86/kernel/cpu/perf_counter.c | |||
@@ -292,15 +292,15 @@ static int __hw_perf_counter_init(struct perf_counter *counter) | |||
292 | /* | 292 | /* |
293 | * Raw event type provide the config in the event structure | 293 | * Raw event type provide the config in the event structure |
294 | */ | 294 | */ |
295 | if (perf_event_raw(attr)) { | 295 | if (attr->type == PERF_TYPE_RAW) { |
296 | hwc->config |= x86_pmu.raw_event(perf_event_config(attr)); | 296 | hwc->config |= x86_pmu.raw_event(attr->config); |
297 | } else { | 297 | } else { |
298 | if (perf_event_id(attr) >= x86_pmu.max_events) | 298 | if (attr->config >= x86_pmu.max_events) |
299 | return -EINVAL; | 299 | return -EINVAL; |
300 | /* | 300 | /* |
301 | * The generic map: | 301 | * The generic map: |
302 | */ | 302 | */ |
303 | hwc->config |= x86_pmu.event_map(perf_event_id(attr)); | 303 | hwc->config |= x86_pmu.event_map(attr->config); |
304 | } | 304 | } |
305 | 305 | ||
306 | counter->destroy = hw_perf_counter_destroy; | 306 | counter->destroy = hw_perf_counter_destroy; |