Skip to content

Commit e1ab48b

Browse files
WangNan0acmel
authored andcommitted
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 <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: He Kuang <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Li Zefan <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Zefan Li <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Wang Nan <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c45c86e commit e1ab48b

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

tools/perf/builtin-record.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,29 @@ static void record__init_features(struct record *rec)
468468
perf_header__clear_feat(&session->header, HEADER_STAT);
469469
}
470470

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+
471494
static volatile int workload_exec_errno;
472495

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

788-
if (!err && !file->is_pipe) {
789-
rec->session->header.data_size += rec->bytes_written;
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-
}
811+
if (!err)
812+
record__finish_output(rec);
800813

801814
if (!err && !quiet) {
802815
char samples[128];

0 commit comments

Comments
 (0)