diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-02-26 04:32:10 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-03-03 09:10:35 -0500 |
commit | e1ab48ba63ee6b2494a67bb60bf99692ecdaca7c (patch) | |
tree | 04f443e8b9614af044cc3839ea9abcc2b7ef7f69 | |
parent | c45c86eb70964615bd13b4c1e647bf9ee60c3db9 (diff) |
perf record: Introduce record__finish_output() to finish a perf.data
Move code for finalizing 'perf.data' to record__finish_output(). It will
be used by following commits to split output to multiple files.
Signed-off-by: He Kuang <hekuang@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1456479154-136027-23-git-send-email-wangnan0@huawei.com
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index cb583b49a175..46e2772f838e 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -468,6 +468,29 @@ static void record__init_features(struct record *rec) | |||
468 | perf_header__clear_feat(&session->header, HEADER_STAT); | 468 | perf_header__clear_feat(&session->header, HEADER_STAT); |
469 | } | 469 | } |
470 | 470 | ||
471 | static void | ||
472 | record__finish_output(struct record *rec) | ||
473 | { | ||
474 | struct perf_data_file *file = &rec->file; | ||
475 | int fd = perf_data_file__fd(file); | ||
476 | |||
477 | if (file->is_pipe) | ||
478 | return; | ||
479 | |||
480 | rec->session->header.data_size += rec->bytes_written; | ||
481 | file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR); | ||
482 | |||
483 | if (!rec->no_buildid) { | ||
484 | process_buildids(rec); | ||
485 | |||
486 | if (rec->buildid_all) | ||
487 | dsos__hit_all(rec->session); | ||
488 | } | ||
489 | perf_session__write_header(rec->session, rec->evlist, fd, true); | ||
490 | |||
491 | return; | ||
492 | } | ||
493 | |||
471 | static volatile int workload_exec_errno; | 494 | static volatile int workload_exec_errno; |
472 | 495 | ||
473 | /* | 496 | /* |
@@ -785,18 +808,8 @@ out_child: | |||
785 | /* this will be recalculated during process_buildids() */ | 808 | /* this will be recalculated during process_buildids() */ |
786 | rec->samples = 0; | 809 | rec->samples = 0; |
787 | 810 | ||
788 | if (!err && !file->is_pipe) { | 811 | if (!err) |
789 | rec->session->header.data_size += rec->bytes_written; | 812 | record__finish_output(rec); |
790 | file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR); | ||
791 | |||
792 | if (!rec->no_buildid) { | ||
793 | process_buildids(rec); | ||
794 | |||
795 | if (rec->buildid_all) | ||
796 | dsos__hit_all(rec->session); | ||
797 | } | ||
798 | perf_session__write_header(rec->session, rec->evlist, fd, true); | ||
799 | } | ||
800 | 813 | ||
801 | if (!err && !quiet) { | 814 | if (!err && !quiet) { |
802 | char samples[128]; | 815 | char samples[128]; |