aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2013-10-31 12:29:29 -0400
committerIngo Molnar <mingo@kernel.org>2013-11-06 06:34:21 -0500
commitd20a973f46ed83e0d7d24f6c512064133038e193 (patch)
tree67480d93b9ed6b23cede1e861aa4daf4bf345782
parent85f59edf9684603026c64c902791748116d29478 (diff)
perf: Optimize perf_output_begin() -- lost_event case
Avoid touching the lost_event and sample_data cachelines twince. Its not like we end up doing less work, but it might help to keep all accesses to these cachelines in one place. Due to code shuffle, this looses 4 bytes on x86_64-defconfig. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Cc: Michael Ellerman <michael@ellerman.id.au> Cc: Michael Neuling <mikey@neuling.org> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: james.hogan@imgtec.com Cc: Vince Weaver <vince@deater.net> Cc: Victor Kaplansky <VICTORK@il.ibm.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Anton Blanchard <anton@samba.org> Link: http://lkml.kernel.org/n/tip-zfxnc58qxj0eawdoj31hhupv@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--kernel/events/ring_buffer.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 6ed16ecfd0a3..e4d70f33792f 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -106,7 +106,6 @@ int perf_output_begin(struct perf_output_handle *handle,
106 struct ring_buffer *rb; 106 struct ring_buffer *rb;
107 unsigned long tail, offset, head; 107 unsigned long tail, offset, head;
108 int have_lost; 108 int have_lost;
109 struct perf_sample_data sample_data;
110 struct { 109 struct {
111 struct perf_event_header header; 110 struct perf_event_header header;
112 u64 id; 111 u64 id;
@@ -132,10 +131,9 @@ int perf_output_begin(struct perf_output_handle *handle,
132 131
133 have_lost = local_read(&rb->lost); 132 have_lost = local_read(&rb->lost);
134 if (unlikely(have_lost)) { 133 if (unlikely(have_lost)) {
135 lost_event.header.size = sizeof(lost_event); 134 size += sizeof(lost_event);
136 perf_event_header__init_id(&lost_event.header, &sample_data, 135 if (event->attr.sample_id_all)
137 event); 136 size += event->id_header_size;
138 size += lost_event.header.size;
139 } 137 }
140 138
141 perf_output_get_handle(handle); 139 perf_output_get_handle(handle);
@@ -169,11 +167,16 @@ int perf_output_begin(struct perf_output_handle *handle,
169 handle->size = (PAGE_SIZE << page_order(rb)) - handle->size; 167 handle->size = (PAGE_SIZE << page_order(rb)) - handle->size;
170 168
171 if (unlikely(have_lost)) { 169 if (unlikely(have_lost)) {
170 struct perf_sample_data sample_data;
171
172 lost_event.header.size = sizeof(lost_event);
172 lost_event.header.type = PERF_RECORD_LOST; 173 lost_event.header.type = PERF_RECORD_LOST;
173 lost_event.header.misc = 0; 174 lost_event.header.misc = 0;
174 lost_event.id = event->id; 175 lost_event.id = event->id;
175 lost_event.lost = local_xchg(&rb->lost, 0); 176 lost_event.lost = local_xchg(&rb->lost, 0);
176 177
178 perf_event_header__init_id(&lost_event.header,
179 &sample_data, event);
177 perf_output_put(handle, lost_event); 180 perf_output_put(handle, lost_event);
178 perf_event__output_id_sample(event, handle, &sample_data); 181 perf_event__output_id_sample(event, handle, &sample_data);
179 } 182 }