Skip to content

Commit

Permalink
perf record: Introduce record__finish_output() to finish a perf.data
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wang Nan authored and Arnaldo Carvalho de Melo committed Mar 3, 2016
1 parent c45c86e commit e1ab48b
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,29 @@ static void record__init_features(struct record *rec)
perf_header__clear_feat(&session->header, HEADER_STAT);
}

static void
record__finish_output(struct record *rec)
{
struct perf_data_file *file = &rec->file;
int fd = perf_data_file__fd(file);

if (file->is_pipe)
return;

rec->session->header.data_size += rec->bytes_written;
file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);

if (!rec->no_buildid) {
process_buildids(rec);

if (rec->buildid_all)
dsos__hit_all(rec->session);
}
perf_session__write_header(rec->session, rec->evlist, fd, true);

return;
}

static volatile int workload_exec_errno;

/*
Expand Down Expand Up @@ -785,18 +808,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
/* this will be recalculated during process_buildids() */
rec->samples = 0;

if (!err && !file->is_pipe) {
rec->session->header.data_size += rec->bytes_written;
file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR);

if (!rec->no_buildid) {
process_buildids(rec);

if (rec->buildid_all)
dsos__hit_all(rec->session);
}
perf_session__write_header(rec->session, rec->evlist, fd, true);
}
if (!err)
record__finish_output(rec);

if (!err && !quiet) {
char samples[128];
Expand Down

0 comments on commit e1ab48b

Please sign in to comment.