diff options
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 1134de22979e..9900b433e861 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -190,6 +190,19 @@ out: | |||
190 | return rc; | 190 | return rc; |
191 | } | 191 | } |
192 | 192 | ||
193 | static int process_sample_event(struct perf_tool *tool, | ||
194 | union perf_event *event, | ||
195 | struct perf_sample *sample, | ||
196 | struct perf_evsel *evsel, | ||
197 | struct machine *machine) | ||
198 | { | ||
199 | struct record *rec = container_of(tool, struct record, tool); | ||
200 | |||
201 | rec->samples++; | ||
202 | |||
203 | return build_id__mark_dso_hit(tool, event, sample, evsel, machine); | ||
204 | } | ||
205 | |||
193 | static int process_buildids(struct record *rec) | 206 | static int process_buildids(struct record *rec) |
194 | { | 207 | { |
195 | struct perf_data_file *file = &rec->file; | 208 | struct perf_data_file *file = &rec->file; |
@@ -212,7 +225,7 @@ static int process_buildids(struct record *rec) | |||
212 | */ | 225 | */ |
213 | symbol_conf.ignore_vmlinux_buildid = true; | 226 | symbol_conf.ignore_vmlinux_buildid = true; |
214 | 227 | ||
215 | return perf_session__process_events(session, &build_id__mark_dso_hit_ops); | 228 | return perf_session__process_events(session, &rec->tool); |
216 | } | 229 | } |
217 | 230 | ||
218 | static void perf_event__synthesize_guest_os(struct machine *machine, void *data) | 231 | static void perf_event__synthesize_guest_os(struct machine *machine, void *data) |
@@ -503,19 +516,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
503 | goto out_child; | 516 | goto out_child; |
504 | } | 517 | } |
505 | 518 | ||
506 | if (!quiet) { | 519 | if (!quiet) |
507 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); | 520 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); |
508 | 521 | ||
509 | /* | ||
510 | * Approximate RIP event size: 24 bytes. | ||
511 | */ | ||
512 | fprintf(stderr, | ||
513 | "[ perf record: Captured and wrote %.3f MB %s (~%" PRIu64 " samples) ]\n", | ||
514 | (double)rec->bytes_written / 1024.0 / 1024.0, | ||
515 | file->path, | ||
516 | rec->bytes_written / 24); | ||
517 | } | ||
518 | |||
519 | out_child: | 522 | out_child: |
520 | if (forks) { | 523 | if (forks) { |
521 | int exit_status; | 524 | int exit_status; |
@@ -534,6 +537,9 @@ out_child: | |||
534 | } else | 537 | } else |
535 | status = err; | 538 | status = err; |
536 | 539 | ||
540 | /* this will be recalculated during process_buildids() */ | ||
541 | rec->samples = 0; | ||
542 | |||
537 | if (!err && !file->is_pipe) { | 543 | if (!err && !file->is_pipe) { |
538 | rec->session->header.data_size += rec->bytes_written; | 544 | rec->session->header.data_size += rec->bytes_written; |
539 | 545 | ||
@@ -543,6 +549,20 @@ out_child: | |||
543 | file->fd, true); | 549 | file->fd, true); |
544 | } | 550 | } |
545 | 551 | ||
552 | if (!err && !quiet) { | ||
553 | char samples[128]; | ||
554 | |||
555 | if (rec->samples) | ||
556 | scnprintf(samples, sizeof(samples), | ||
557 | " (%" PRIu64 " samples)", rec->samples); | ||
558 | else | ||
559 | samples[0] = '\0'; | ||
560 | |||
561 | fprintf(stderr, "[ perf record: Captured and wrote %.3f MB %s%s ]\n", | ||
562 | perf_data_file__size(file) / 1024.0 / 1024.0, | ||
563 | file->path, samples); | ||
564 | } | ||
565 | |||
546 | out_delete_session: | 566 | out_delete_session: |
547 | perf_session__delete(session); | 567 | perf_session__delete(session); |
548 | return status; | 568 | return status; |
@@ -719,6 +739,13 @@ static struct record record = { | |||
719 | .default_per_cpu = true, | 739 | .default_per_cpu = true, |
720 | }, | 740 | }, |
721 | }, | 741 | }, |
742 | .tool = { | ||
743 | .sample = process_sample_event, | ||
744 | .fork = perf_event__process_fork, | ||
745 | .comm = perf_event__process_comm, | ||
746 | .mmap = perf_event__process_mmap, | ||
747 | .mmap2 = perf_event__process_mmap2, | ||
748 | }, | ||
722 | }; | 749 | }; |
723 | 750 | ||
724 | #define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: " | 751 | #define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace) recording: " |