[PATCH 6/8] perf: optimize __perf_sw_event()

Peter Zijlstra
2009-11-23T10:41:29Z

[-- Attachment #1: perf-foo-6.patch --]
[-- Type: text/plain, Size: 1058 bytes --]

From: Ingo Molnar <mingo@elte.hu>

Ingo noticed that the C99 initialisation of the structure resulted in
a memset() and an assignment. Use explicit assignments to avoid the
memset.

perf_prepare_sample() initializes all data entries, except:
addr, period and raw.

period is set in perf_swevent_overflow, addr is set here, leaving only
raw to be dealt with, so clear that explicitly as well.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/perf_event.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -3945,9 +3945,10 @@ out:
void __perf_sw_event(u32 event_id, u64 nr, int nmi,
struct pt_regs *regs, u64 addr)
{
- struct perf_sample_data data = {
- .addr = addr,
- };
+ struct perf_sample_data data;
+
+ data.addr = addr;
+ data.raw = NULL;

do_perf_sw_event(PERF_TYPE_SOFTWARE, event_id, nr, nmi,
&data, regs);

--