aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-record.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-02-03 13:52:05 -0500
committerIngo Molnar <mingo@elte.hu>2010-02-04 03:33:27 -0500
commit6122e4e4f5d0913e319ef8a4dc60a47afe4abc0a (patch)
tree77e8995f360f3cb3a8f7c392708ccf58836b0573 /tools/perf/builtin-record.c
parent7b2567c1f57c059de29d3f2ca03aca84473865c8 (diff)
perf record: Stop intercepting events, use postprocessing to get build-ids
We want to stream events as fast as possible to perf.data, and also in the future we want to have splice working, when no interception will be possible. Using build_id__mark_dso_hit_ops to create the list of DSOs that back MMAPs we also optimize disk usage in the build-id cache by only caching DSOs that had hits. Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1265223128-11786-6-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r--tools/perf/builtin-record.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 949167efa1ed..706f00196b87 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -12,6 +12,7 @@
12 12
13#include "perf.h" 13#include "perf.h"
14 14
15#include "util/build-id.h"
15#include "util/util.h" 16#include "util/util.h"
16#include "util/parse-options.h" 17#include "util/parse-options.h"
17#include "util/parse-events.h" 18#include "util/parse-events.h"
@@ -65,6 +66,7 @@ static int nr_poll = 0;
65static int nr_cpu = 0; 66static int nr_cpu = 0;
66 67
67static int file_new = 1; 68static int file_new = 1;
69static off_t post_processing_offset;
68 70
69static struct perf_session *session; 71static struct perf_session *session;
70 72
@@ -114,26 +116,10 @@ static void write_output(void *buf, size_t size)
114 } 116 }
115} 117}
116 118
117static void write_event(event_t *buf, size_t size)
118{
119 /*
120 * Add it to the list of DSOs, so that when we finish this
121 * record session we can pick the available build-ids.
122 */
123 if (buf->header.type == PERF_RECORD_MMAP) {
124 struct list_head *head = &dsos__user;
125 if (buf->mmap.header.misc == 1)
126 head = &dsos__kernel;
127 __dsos__findnew(head, buf->mmap.filename);
128 }
129
130 write_output(buf, size);
131}
132
133static int process_synthesized_event(event_t *event, 119static int process_synthesized_event(event_t *event,
134 struct perf_session *self __used) 120 struct perf_session *self __used)
135{ 121{
136 write_event(event, event->header.size); 122 write_output(event, event->header.size);
137 return 0; 123 return 0;
138} 124}
139 125
@@ -185,14 +171,14 @@ static void mmap_read(struct mmap_data *md)
185 size = md->mask + 1 - (old & md->mask); 171 size = md->mask + 1 - (old & md->mask);
186 old += size; 172 old += size;
187 173
188 write_event(buf, size); 174 write_output(buf, size);
189 } 175 }
190 176
191 buf = &data[old & md->mask]; 177 buf = &data[old & md->mask];
192 size = head - old; 178 size = head - old;
193 old += size; 179 old += size;
194 180
195 write_event(buf, size); 181 write_output(buf, size);
196 182
197 md->prev = old; 183 md->prev = old;
198 mmap_write_tail(md, old); 184 mmap_write_tail(md, old);
@@ -402,10 +388,21 @@ static void open_counters(int cpu, pid_t pid)
402 nr_cpu++; 388 nr_cpu++;
403} 389}
404 390
391static int process_buildids(void)
392{
393 u64 size = lseek(output, 0, SEEK_CUR);
394
395 session->fd = output;
396 return __perf_session__process_events(session, post_processing_offset,
397 size - post_processing_offset,
398 size, &build_id__mark_dso_hit_ops);
399}
400
405static void atexit_header(void) 401static void atexit_header(void)
406{ 402{
407 session->header.data_size += bytes_written; 403 session->header.data_size += bytes_written;
408 404
405 process_buildids();
409 perf_header__write(&session->header, output, true); 406 perf_header__write(&session->header, output, true);
410} 407}
411 408
@@ -558,6 +555,8 @@ static int __cmd_record(int argc, const char **argv)
558 return err; 555 return err;
559 } 556 }
560 557
558 post_processing_offset = lseek(output, 0, SEEK_CUR);
559
561 err = event__synthesize_kernel_mmap(process_synthesized_event, 560 err = event__synthesize_kernel_mmap(process_synthesized_event,
562 session, "_text"); 561 session, "_text");
563 if (err < 0) { 562 if (err < 0) {