diff options
author | Peter Zijlstra <peterz@infradead.org> | 2010-03-18 21:00:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-01 19:01:29 -0400 |
commit | 06432c9591a2607d70580333a50aba19344e2e40 (patch) | |
tree | cb1706f959b0dc06ef81ef1cd8378f634be53155 /arch | |
parent | f3cfe648b427db8768a1039cfd201842ae8a4a1d (diff) |
perf: Provide generic perf_sample_data initialization
This makes it easier to extend perf_sample_data and fixes a bug on arm
and sparc, which failed to set ->raw to NULL, which can cause crashes
when combined with PERF_SAMPLE_RAW.
It also optimizes PowerPC and tracepoint, because the struct
initialization is forced to zero out the whole structure.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Jean Pihet <jpihet@mvista.com>
Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Jamie Iles <jamie.iles@picochip.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <20100304140100.315416040@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/perf_event.c | 8 | ||||
-rw-r--r-- | arch/sparc/kernel/perf_event.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_event.c | 9 |
3 files changed, 8 insertions, 11 deletions
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c index 1eb85fbf53a5..a3c0a32c4628 100644 --- a/arch/powerpc/kernel/perf_event.c +++ b/arch/powerpc/kernel/perf_event.c | |||
@@ -1164,10 +1164,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val, | |||
1164 | * Finally record data if requested. | 1164 | * Finally record data if requested. |
1165 | */ | 1165 | */ |
1166 | if (record) { | 1166 | if (record) { |
1167 | struct perf_sample_data data = { | 1167 | struct perf_sample_data data; |
1168 | .addr = ~0ULL, | 1168 | |
1169 | .period = event->hw.last_period, | 1169 | perf_sample_data_init(&data, ~0ULL); |
1170 | }; | 1170 | data.period = event->hw.last_period; |
1171 | 1171 | ||
1172 | if (event->attr.sample_type & PERF_SAMPLE_ADDR) | 1172 | if (event->attr.sample_type & PERF_SAMPLE_ADDR) |
1173 | perf_get_data_addr(regs, &data.addr); | 1173 | perf_get_data_addr(regs, &data.addr); |
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c index e856456ec02f..87b504930633 100644 --- a/arch/sparc/kernel/perf_event.c +++ b/arch/sparc/kernel/perf_event.c | |||
@@ -1189,7 +1189,7 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self, | |||
1189 | 1189 | ||
1190 | regs = args->regs; | 1190 | regs = args->regs; |
1191 | 1191 | ||
1192 | data.addr = 0; | 1192 | perf_sample_data_init(&data, 0); |
1193 | 1193 | ||
1194 | cpuc = &__get_cpu_var(cpu_hw_events); | 1194 | cpuc = &__get_cpu_var(cpu_hw_events); |
1195 | 1195 | ||
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 8c1c07073ccc..98819b32bb5f 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c | |||
@@ -1636,10 +1636,9 @@ static void intel_pmu_drain_bts_buffer(struct cpu_hw_events *cpuc) | |||
1636 | 1636 | ||
1637 | ds->bts_index = ds->bts_buffer_base; | 1637 | ds->bts_index = ds->bts_buffer_base; |
1638 | 1638 | ||
1639 | perf_sample_data_init(&data, 0); | ||
1639 | 1640 | ||
1640 | data.period = event->hw.last_period; | 1641 | data.period = event->hw.last_period; |
1641 | data.addr = 0; | ||
1642 | data.raw = NULL; | ||
1643 | regs.ip = 0; | 1642 | regs.ip = 0; |
1644 | 1643 | ||
1645 | /* | 1644 | /* |
@@ -1756,8 +1755,7 @@ static int p6_pmu_handle_irq(struct pt_regs *regs) | |||
1756 | int idx, handled = 0; | 1755 | int idx, handled = 0; |
1757 | u64 val; | 1756 | u64 val; |
1758 | 1757 | ||
1759 | data.addr = 0; | 1758 | perf_sample_data_init(&data, 0); |
1760 | data.raw = NULL; | ||
1761 | 1759 | ||
1762 | cpuc = &__get_cpu_var(cpu_hw_events); | 1760 | cpuc = &__get_cpu_var(cpu_hw_events); |
1763 | 1761 | ||
@@ -1802,8 +1800,7 @@ static int intel_pmu_handle_irq(struct pt_regs *regs) | |||
1802 | int bit, loops; | 1800 | int bit, loops; |
1803 | u64 ack, status; | 1801 | u64 ack, status; |
1804 | 1802 | ||
1805 | data.addr = 0; | 1803 | perf_sample_data_init(&data, 0); |
1806 | data.raw = NULL; | ||
1807 | 1804 | ||
1808 | cpuc = &__get_cpu_var(cpu_hw_events); | 1805 | cpuc = &__get_cpu_var(cpu_hw_events); |
1809 | 1806 | ||