aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-annotate.c10
-rw-r--r--tools/perf/builtin-buildid-cache.c8
-rw-r--r--tools/perf/builtin-buildid-list.c8
-rw-r--r--tools/perf/builtin-c2c.c10
-rw-r--r--tools/perf/builtin-diff.c18
-rw-r--r--tools/perf/builtin-evlist.c4
-rw-r--r--tools/perf/builtin-inject.c26
-rw-r--r--tools/perf/builtin-kmem.c8
-rw-r--r--tools/perf/builtin-kvm.c6
-rw-r--r--tools/perf/builtin-lock.c4
-rw-r--r--tools/perf/builtin-mem.c4
-rw-r--r--tools/perf/builtin-record.c50
-rw-r--r--tools/perf/builtin-report.c14
-rw-r--r--tools/perf/builtin-sched.c8
-rw-r--r--tools/perf/builtin-script.c20
-rw-r--r--tools/perf/builtin-stat.c32
-rw-r--r--tools/perf/builtin-timechart.c6
-rw-r--r--tools/perf/builtin-trace.c4
-rw-r--r--tools/perf/tests/topology.c10
-rw-r--r--tools/perf/util/auxtrace.c4
-rw-r--r--tools/perf/util/data-convert-bt.c6
-rw-r--r--tools/perf/util/data.c92
-rw-r--r--tools/perf/util/data.h32
-rw-r--r--tools/perf/util/header.c20
-rw-r--r--tools/perf/util/intel-bts.c6
-rw-r--r--tools/perf/util/intel-pt.c6
-rw-r--r--tools/perf/util/jit.h2
-rw-r--r--tools/perf/util/jitdump.c10
-rw-r--r--tools/perf/util/session.c44
-rw-r--r--tools/perf/util/session.h4
30 files changed, 238 insertions, 238 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index c38373195c4a..2d06be81a109 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -356,7 +356,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
356 } 356 }
357 357
358 if (total_nr_samples == 0) { 358 if (total_nr_samples == 0) {
359 ui__error("The %s file has no samples!\n", session->file->path); 359 ui__error("The %s file has no samples!\n", session->data->path);
360 goto out; 360 goto out;
361 } 361 }
362 362
@@ -400,7 +400,7 @@ int cmd_annotate(int argc, const char **argv)
400 .ordering_requires_timestamps = true, 400 .ordering_requires_timestamps = true,
401 }, 401 },
402 }; 402 };
403 struct perf_data_file file = { 403 struct perf_data data = {
404 .mode = PERF_DATA_MODE_READ, 404 .mode = PERF_DATA_MODE_READ,
405 }; 405 };
406 struct option options[] = { 406 struct option options[] = {
@@ -410,7 +410,7 @@ int cmd_annotate(int argc, const char **argv)
410 "only consider symbols in these dsos"), 410 "only consider symbols in these dsos"),
411 OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol", 411 OPT_STRING('s', "symbol", &annotate.sym_hist_filter, "symbol",
412 "symbol to annotate"), 412 "symbol to annotate"),
413 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), 413 OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"),
414 OPT_INCR('v', "verbose", &verbose, 414 OPT_INCR('v', "verbose", &verbose,
415 "be more verbose (show symbol address, etc)"), 415 "be more verbose (show symbol address, etc)"),
416 OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"), 416 OPT_BOOLEAN('q', "quiet", &quiet, "do now show any message"),
@@ -482,9 +482,9 @@ int cmd_annotate(int argc, const char **argv)
482 if (quiet) 482 if (quiet)
483 perf_quiet_option(); 483 perf_quiet_option();
484 484
485 file.path = input_name; 485 data.path = input_name;
486 486
487 annotate.session = perf_session__new(&file, false, &annotate.tool); 487 annotate.session = perf_session__new(&data, false, &annotate.tool);
488 if (annotate.session == NULL) 488 if (annotate.session == NULL)
489 return -1; 489 return -1;
490 490
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
index e3eb6240ced0..9fceae47a02e 100644
--- a/tools/perf/builtin-buildid-cache.c
+++ b/tools/perf/builtin-buildid-cache.c
@@ -311,7 +311,7 @@ int cmd_buildid_cache(int argc, const char **argv)
311 *kcore_filename = NULL; 311 *kcore_filename = NULL;
312 char sbuf[STRERR_BUFSIZE]; 312 char sbuf[STRERR_BUFSIZE];
313 313
314 struct perf_data_file file = { 314 struct perf_data data = {
315 .mode = PERF_DATA_MODE_READ, 315 .mode = PERF_DATA_MODE_READ,
316 }; 316 };
317 struct perf_session *session = NULL; 317 struct perf_session *session = NULL;
@@ -352,10 +352,10 @@ int cmd_buildid_cache(int argc, const char **argv)
352 nsi = nsinfo__new(ns_id); 352 nsi = nsinfo__new(ns_id);
353 353
354 if (missing_filename) { 354 if (missing_filename) {
355 file.path = missing_filename; 355 data.path = missing_filename;
356 file.force = force; 356 data.force = force;
357 357
358 session = perf_session__new(&file, false, NULL); 358 session = perf_session__new(&data, false, NULL);
359 if (session == NULL) 359 if (session == NULL)
360 return -1; 360 return -1;
361 } 361 }
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index fdaca16e0c74..72bdc0eba990 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -50,7 +50,7 @@ static bool dso__skip_buildid(struct dso *dso, int with_hits)
50static int perf_session__list_build_ids(bool force, bool with_hits) 50static int perf_session__list_build_ids(bool force, bool with_hits)
51{ 51{
52 struct perf_session *session; 52 struct perf_session *session;
53 struct perf_data_file file = { 53 struct perf_data data = {
54 .path = input_name, 54 .path = input_name,
55 .mode = PERF_DATA_MODE_READ, 55 .mode = PERF_DATA_MODE_READ,
56 .force = force, 56 .force = force,
@@ -63,7 +63,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
63 if (filename__fprintf_build_id(input_name, stdout) > 0) 63 if (filename__fprintf_build_id(input_name, stdout) > 0)
64 goto out; 64 goto out;
65 65
66 session = perf_session__new(&file, false, &build_id__mark_dso_hit_ops); 66 session = perf_session__new(&data, false, &build_id__mark_dso_hit_ops);
67 if (session == NULL) 67 if (session == NULL)
68 return -1; 68 return -1;
69 69
@@ -71,7 +71,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
71 * We take all buildids when the file contains AUX area tracing data 71 * We take all buildids when the file contains AUX area tracing data
72 * because we do not decode the trace because it would take too long. 72 * because we do not decode the trace because it would take too long.
73 */ 73 */
74 if (!perf_data_file__is_pipe(&file) && 74 if (!perf_data__is_pipe(&data) &&
75 perf_header__has_feat(&session->header, HEADER_AUXTRACE)) 75 perf_header__has_feat(&session->header, HEADER_AUXTRACE))
76 with_hits = false; 76 with_hits = false;
77 77
@@ -79,7 +79,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
79 * in pipe-mode, the only way to get the buildids is to parse 79 * in pipe-mode, the only way to get the buildids is to parse
80 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID 80 * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID
81 */ 81 */
82 if (with_hits || perf_data_file__is_pipe(&file)) 82 if (with_hits || perf_data__is_pipe(&data))
83 perf_session__process_events(session); 83 perf_session__process_events(session);
84 84
85 perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits); 85 perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits);
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index bb1ee22bd221..87a52d09da29 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2523,7 +2523,7 @@ static int perf_c2c__report(int argc, const char **argv)
2523{ 2523{
2524 struct perf_session *session; 2524 struct perf_session *session;
2525 struct ui_progress prog; 2525 struct ui_progress prog;
2526 struct perf_data_file file = { 2526 struct perf_data data = {
2527 .mode = PERF_DATA_MODE_READ, 2527 .mode = PERF_DATA_MODE_READ,
2528 }; 2528 };
2529 char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT; 2529 char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT;
@@ -2572,8 +2572,8 @@ static int perf_c2c__report(int argc, const char **argv)
2572 if (!input_name || !strlen(input_name)) 2572 if (!input_name || !strlen(input_name))
2573 input_name = "perf.data"; 2573 input_name = "perf.data";
2574 2574
2575 file.path = input_name; 2575 data.path = input_name;
2576 file.force = symbol_conf.force; 2576 data.force = symbol_conf.force;
2577 2577
2578 err = setup_display(display); 2578 err = setup_display(display);
2579 if (err) 2579 if (err)
@@ -2591,7 +2591,7 @@ static int perf_c2c__report(int argc, const char **argv)
2591 goto out; 2591 goto out;
2592 } 2592 }
2593 2593
2594 session = perf_session__new(&file, 0, &c2c.tool); 2594 session = perf_session__new(&data, 0, &c2c.tool);
2595 if (session == NULL) { 2595 if (session == NULL) {
2596 pr_debug("No memory for session\n"); 2596 pr_debug("No memory for session\n");
2597 goto out; 2597 goto out;
@@ -2611,7 +2611,7 @@ static int perf_c2c__report(int argc, const char **argv)
2611 goto out_session; 2611 goto out_session;
2612 2612
2613 /* No pipe support at the moment. */ 2613 /* No pipe support at the moment. */
2614 if (perf_data_file__is_pipe(session->file)) { 2614 if (perf_data__is_pipe(session->data)) {
2615 pr_debug("No pipe support at the moment.\n"); 2615 pr_debug("No pipe support at the moment.\n");
2616 goto out_session; 2616 goto out_session;
2617 } 2617 }
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 0cd4cf6a344b..5292e3d13cec 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -47,7 +47,7 @@ struct diff_hpp_fmt {
47 47
48struct data__file { 48struct data__file {
49 struct perf_session *session; 49 struct perf_session *session;
50 struct perf_data_file file; 50 struct perf_data data;
51 int idx; 51 int idx;
52 struct hists *hists; 52 struct hists *hists;
53 struct diff_hpp_fmt fmt[PERF_HPP_DIFF__MAX_INDEX]; 53 struct diff_hpp_fmt fmt[PERF_HPP_DIFF__MAX_INDEX];
@@ -707,7 +707,7 @@ static void data__fprintf(void)
707 707
708 data__for_each_file(i, d) 708 data__for_each_file(i, d)
709 fprintf(stdout, "# [%d] %s %s\n", 709 fprintf(stdout, "# [%d] %s %s\n",
710 d->idx, d->file.path, 710 d->idx, d->data.path,
711 !d->idx ? "(Baseline)" : ""); 711 !d->idx ? "(Baseline)" : "");
712 712
713 fprintf(stdout, "#\n"); 713 fprintf(stdout, "#\n");
@@ -776,16 +776,16 @@ static int __cmd_diff(void)
776 int ret = -EINVAL, i; 776 int ret = -EINVAL, i;
777 777
778 data__for_each_file(i, d) { 778 data__for_each_file(i, d) {
779 d->session = perf_session__new(&d->file, false, &tool); 779 d->session = perf_session__new(&d->data, false, &tool);
780 if (!d->session) { 780 if (!d->session) {
781 pr_err("Failed to open %s\n", d->file.path); 781 pr_err("Failed to open %s\n", d->data.path);
782 ret = -1; 782 ret = -1;
783 goto out_delete; 783 goto out_delete;
784 } 784 }
785 785
786 ret = perf_session__process_events(d->session); 786 ret = perf_session__process_events(d->session);
787 if (ret) { 787 if (ret) {
788 pr_err("Failed to process %s\n", d->file.path); 788 pr_err("Failed to process %s\n", d->data.path);
789 goto out_delete; 789 goto out_delete;
790 } 790 }
791 791
@@ -1286,11 +1286,11 @@ static int data_init(int argc, const char **argv)
1286 return -ENOMEM; 1286 return -ENOMEM;
1287 1287
1288 data__for_each_file(i, d) { 1288 data__for_each_file(i, d) {
1289 struct perf_data_file *file = &d->file; 1289 struct perf_data *data = &d->data;
1290 1290
1291 file->path = use_default ? defaults[i] : argv[i]; 1291 data->path = use_default ? defaults[i] : argv[i];
1292 file->mode = PERF_DATA_MODE_READ, 1292 data->mode = PERF_DATA_MODE_READ,
1293 file->force = force, 1293 data->force = force,
1294 1294
1295 d->idx = i; 1295 d->idx = i;
1296 } 1296 }
diff --git a/tools/perf/builtin-evlist.c b/tools/perf/builtin-evlist.c
index 6d210e40d611..cd79c26e16a4 100644
--- a/tools/perf/builtin-evlist.c
+++ b/tools/perf/builtin-evlist.c
@@ -21,14 +21,14 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
21{ 21{
22 struct perf_session *session; 22 struct perf_session *session;
23 struct perf_evsel *pos; 23 struct perf_evsel *pos;
24 struct perf_data_file file = { 24 struct perf_data data = {
25 .path = file_name, 25 .path = file_name,
26 .mode = PERF_DATA_MODE_READ, 26 .mode = PERF_DATA_MODE_READ,
27 .force = details->force, 27 .force = details->force,
28 }; 28 };
29 bool has_tracepoint = false; 29 bool has_tracepoint = false;
30 30
31 session = perf_session__new(&file, 0, NULL); 31 session = perf_session__new(&data, 0, NULL);
32 if (session == NULL) 32 if (session == NULL)
33 return -1; 33 return -1;
34 34
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 2b8032908fb2..ac7486f6c46f 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -35,7 +35,7 @@ struct perf_inject {
35 bool strip; 35 bool strip;
36 bool jit_mode; 36 bool jit_mode;
37 const char *input_name; 37 const char *input_name;
38 struct perf_data_file output; 38 struct perf_data output;
39 u64 bytes_written; 39 u64 bytes_written;
40 u64 aux_id; 40 u64 aux_id;
41 struct list_head samples; 41 struct list_head samples;
@@ -52,7 +52,7 @@ static int output_bytes(struct perf_inject *inject, void *buf, size_t sz)
52{ 52{
53 ssize_t size; 53 ssize_t size;
54 54
55 size = perf_data_file__write(&inject->output, buf, sz); 55 size = perf_data__write(&inject->output, buf, sz);
56 if (size < 0) 56 if (size < 0)
57 return -errno; 57 return -errno;
58 58
@@ -154,11 +154,11 @@ static s64 perf_event__repipe_auxtrace(struct perf_tool *tool,
154 return ret; 154 return ret;
155 } 155 }
156 156
157 if (perf_data_file__is_pipe(session->file) || !session->one_mmap) { 157 if (perf_data__is_pipe(session->data) || !session->one_mmap) {
158 ret = output_bytes(inject, event, event->header.size); 158 ret = output_bytes(inject, event, event->header.size);
159 if (ret < 0) 159 if (ret < 0)
160 return ret; 160 return ret;
161 ret = copy_bytes(inject, perf_data_file__fd(session->file), 161 ret = copy_bytes(inject, perf_data__fd(session->data),
162 event->auxtrace.size); 162 event->auxtrace.size);
163 } else { 163 } else {
164 ret = output_bytes(inject, event, 164 ret = output_bytes(inject, event,
@@ -637,8 +637,8 @@ static int __cmd_inject(struct perf_inject *inject)
637{ 637{
638 int ret = -EINVAL; 638 int ret = -EINVAL;
639 struct perf_session *session = inject->session; 639 struct perf_session *session = inject->session;
640 struct perf_data_file *file_out = &inject->output; 640 struct perf_data *data_out = &inject->output;
641 int fd = perf_data_file__fd(file_out); 641 int fd = perf_data__fd(data_out);
642 u64 output_data_offset; 642 u64 output_data_offset;
643 643
644 signal(SIGINT, sig_handler); 644 signal(SIGINT, sig_handler);
@@ -693,14 +693,14 @@ static int __cmd_inject(struct perf_inject *inject)
693 if (!inject->itrace_synth_opts.set) 693 if (!inject->itrace_synth_opts.set)
694 auxtrace_index__free(&session->auxtrace_index); 694 auxtrace_index__free(&session->auxtrace_index);
695 695
696 if (!file_out->is_pipe) 696 if (!data_out->is_pipe)
697 lseek(fd, output_data_offset, SEEK_SET); 697 lseek(fd, output_data_offset, SEEK_SET);
698 698
699 ret = perf_session__process_events(session); 699 ret = perf_session__process_events(session);
700 if (ret) 700 if (ret)
701 return ret; 701 return ret;
702 702
703 if (!file_out->is_pipe) { 703 if (!data_out->is_pipe) {
704 if (inject->build_ids) 704 if (inject->build_ids)
705 perf_header__set_feat(&session->header, 705 perf_header__set_feat(&session->header,
706 HEADER_BUILD_ID); 706 HEADER_BUILD_ID);
@@ -779,7 +779,7 @@ int cmd_inject(int argc, const char **argv)
779 .mode = PERF_DATA_MODE_WRITE, 779 .mode = PERF_DATA_MODE_WRITE,
780 }, 780 },
781 }; 781 };
782 struct perf_data_file file = { 782 struct perf_data data = {
783 .mode = PERF_DATA_MODE_READ, 783 .mode = PERF_DATA_MODE_READ,
784 }; 784 };
785 int ret; 785 int ret;
@@ -801,7 +801,7 @@ int cmd_inject(int argc, const char **argv)
801 "be more verbose (show build ids, etc)"), 801 "be more verbose (show build ids, etc)"),
802 OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file", 802 OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file",
803 "kallsyms pathname"), 803 "kallsyms pathname"),
804 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), 804 OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"),
805 OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts, 805 OPT_CALLBACK_OPTARG(0, "itrace", &inject.itrace_synth_opts,
806 NULL, "opts", "Instruction Tracing options", 806 NULL, "opts", "Instruction Tracing options",
807 itrace_parse_synth_opts), 807 itrace_parse_synth_opts),
@@ -829,15 +829,15 @@ int cmd_inject(int argc, const char **argv)
829 return -1; 829 return -1;
830 } 830 }
831 831
832 if (perf_data_file__open(&inject.output)) { 832 if (perf_data__open(&inject.output)) {
833 perror("failed to create output file"); 833 perror("failed to create output file");
834 return -1; 834 return -1;
835 } 835 }
836 836
837 inject.tool.ordered_events = inject.sched_stat; 837 inject.tool.ordered_events = inject.sched_stat;
838 838
839 file.path = inject.input_name; 839 data.path = inject.input_name;
840 inject.session = perf_session__new(&file, true, &inject.tool); 840 inject.session = perf_session__new(&data, true, &inject.tool);
841 if (inject.session == NULL) 841 if (inject.session == NULL)
842 return -1; 842 return -1;
843 843
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index d8f25ef8157b..d45740a3e5f1 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -1893,7 +1893,7 @@ int cmd_kmem(int argc, const char **argv)
1893{ 1893{
1894 const char * const default_slab_sort = "frag,hit,bytes"; 1894 const char * const default_slab_sort = "frag,hit,bytes";
1895 const char * const default_page_sort = "bytes,hit"; 1895 const char * const default_page_sort = "bytes,hit";
1896 struct perf_data_file file = { 1896 struct perf_data data = {
1897 .mode = PERF_DATA_MODE_READ, 1897 .mode = PERF_DATA_MODE_READ,
1898 }; 1898 };
1899 const struct option kmem_options[] = { 1899 const struct option kmem_options[] = {
@@ -1909,7 +1909,7 @@ int cmd_kmem(int argc, const char **argv)
1909 "page, order, migtype, gfp", parse_sort_opt), 1909 "page, order, migtype, gfp", parse_sort_opt),
1910 OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt), 1910 OPT_CALLBACK('l', "line", NULL, "num", "show n lines", parse_line_opt),
1911 OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"), 1911 OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"),
1912 OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"), 1912 OPT_BOOLEAN('f', "force", &data.force, "don't complain, do it"),
1913 OPT_CALLBACK_NOOPT(0, "slab", NULL, NULL, "Analyze slab allocator", 1913 OPT_CALLBACK_NOOPT(0, "slab", NULL, NULL, "Analyze slab allocator",
1914 parse_slab_opt), 1914 parse_slab_opt),
1915 OPT_CALLBACK_NOOPT(0, "page", NULL, NULL, "Analyze page allocator", 1915 OPT_CALLBACK_NOOPT(0, "page", NULL, NULL, "Analyze page allocator",
@@ -1949,9 +1949,9 @@ int cmd_kmem(int argc, const char **argv)
1949 return __cmd_record(argc, argv); 1949 return __cmd_record(argc, argv);
1950 } 1950 }
1951 1951
1952 file.path = input_name; 1952 data.path = input_name;
1953 1953
1954 kmem_session = session = perf_session__new(&file, false, &perf_kmem); 1954 kmem_session = session = perf_session__new(&data, false, &perf_kmem);
1955 if (session == NULL) 1955 if (session == NULL)
1956 return -1; 1956 return -1;
1957 1957
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
index 721f4f91291a..4301fc34f23c 100644
--- a/tools/perf/builtin-kvm.c
+++ b/tools/perf/builtin-kvm.c
@@ -1067,7 +1067,7 @@ static int read_events(struct perf_kvm_stat *kvm)
1067 .namespaces = perf_event__process_namespaces, 1067 .namespaces = perf_event__process_namespaces,
1068 .ordered_events = true, 1068 .ordered_events = true,
1069 }; 1069 };
1070 struct perf_data_file file = { 1070 struct perf_data file = {
1071 .path = kvm->file_name, 1071 .path = kvm->file_name,
1072 .mode = PERF_DATA_MODE_READ, 1072 .mode = PERF_DATA_MODE_READ,
1073 .force = kvm->force, 1073 .force = kvm->force,
@@ -1358,7 +1358,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
1358 "perf kvm stat live [<options>]", 1358 "perf kvm stat live [<options>]",
1359 NULL 1359 NULL
1360 }; 1360 };
1361 struct perf_data_file file = { 1361 struct perf_data data = {
1362 .mode = PERF_DATA_MODE_WRITE, 1362 .mode = PERF_DATA_MODE_WRITE,
1363 }; 1363 };
1364 1364
@@ -1432,7 +1432,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
1432 /* 1432 /*
1433 * perf session 1433 * perf session
1434 */ 1434 */
1435 kvm->session = perf_session__new(&file, false, &kvm->tool); 1435 kvm->session = perf_session__new(&data, false, &kvm->tool);
1436 if (kvm->session == NULL) { 1436 if (kvm->session == NULL) {
1437 err = -1; 1437 err = -1;
1438 goto out; 1438 goto out;
diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
index ff98652484a7..2e281f7b0fca 100644
--- a/tools/perf/builtin-lock.c
+++ b/tools/perf/builtin-lock.c
@@ -864,13 +864,13 @@ static int __cmd_report(bool display_info)
864 .namespaces = perf_event__process_namespaces, 864 .namespaces = perf_event__process_namespaces,
865 .ordered_events = true, 865 .ordered_events = true,
866 }; 866 };
867 struct perf_data_file file = { 867 struct perf_data data = {
868 .path = input_name, 868 .path = input_name,
869 .mode = PERF_DATA_MODE_READ, 869 .mode = PERF_DATA_MODE_READ,
870 .force = force, 870 .force = force,
871 }; 871 };
872 872
873 session = perf_session__new(&file, false, &eops); 873 session = perf_session__new(&data, false, &eops);
874 if (!session) { 874 if (!session) {
875 pr_err("Initializing perf session failed\n"); 875 pr_err("Initializing perf session failed\n");
876 return -1; 876 return -1;
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index 6940490bc3f9..5a4a6f8e614d 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -236,13 +236,13 @@ static int process_sample_event(struct perf_tool *tool,
236 236
237static int report_raw_events(struct perf_mem *mem) 237static int report_raw_events(struct perf_mem *mem)
238{ 238{
239 struct perf_data_file file = { 239 struct perf_data data = {
240 .path = input_name, 240 .path = input_name,
241 .mode = PERF_DATA_MODE_READ, 241 .mode = PERF_DATA_MODE_READ,
242 .force = mem->force, 242 .force = mem->force,
243 }; 243 };
244 int ret; 244 int ret;
245 struct perf_session *session = perf_session__new(&file, false, 245 struct perf_session *session = perf_session__new(&data, false,
246 &mem->tool); 246 &mem->tool);
247 247
248 if (session == NULL) 248 if (session == NULL)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a6cbf1640269..0ab7dd0e4f2b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -66,7 +66,7 @@ struct record {
66 struct perf_tool tool; 66 struct perf_tool tool;
67 struct record_opts opts; 67 struct record_opts opts;
68 u64 bytes_written; 68 u64 bytes_written;
69 struct perf_data_file file; 69 struct perf_data data;
70 struct auxtrace_record *itr; 70 struct auxtrace_record *itr;
71 struct perf_evlist *evlist; 71 struct perf_evlist *evlist;
72 struct perf_session *session; 72 struct perf_session *session;
@@ -107,7 +107,7 @@ static bool switch_output_time(struct record *rec)
107 107
108static int record__write(struct record *rec, void *bf, size_t size) 108static int record__write(struct record *rec, void *bf, size_t size)
109{ 109{
110 if (perf_data_file__write(rec->session->file, bf, size) < 0) { 110 if (perf_data__write(rec->session->data, bf, size) < 0) {
111 pr_err("failed to write perf data, error: %m\n"); 111 pr_err("failed to write perf data, error: %m\n");
112 return -1; 112 return -1;
113 } 113 }
@@ -173,13 +173,13 @@ static int record__process_auxtrace(struct perf_tool *tool,
173 size_t len1, void *data2, size_t len2) 173 size_t len1, void *data2, size_t len2)
174{ 174{
175 struct record *rec = container_of(tool, struct record, tool); 175 struct record *rec = container_of(tool, struct record, tool);
176 struct perf_data_file *file = &rec->file; 176 struct perf_data *data = &rec->data;
177 size_t padding; 177 size_t padding;
178 u8 pad[8] = {0}; 178 u8 pad[8] = {0};
179 179
180 if (!perf_data_file__is_pipe(file)) { 180 if (!perf_data__is_pipe(data)) {
181 off_t file_offset; 181 off_t file_offset;
182 int fd = perf_data_file__fd(file); 182 int fd = perf_data__fd(data);
183 int err; 183 int err;
184 184
185 file_offset = lseek(fd, 0, SEEK_CUR); 185 file_offset = lseek(fd, 0, SEEK_CUR);
@@ -398,10 +398,10 @@ static int process_sample_event(struct perf_tool *tool,
398 398
399static int process_buildids(struct record *rec) 399static int process_buildids(struct record *rec)
400{ 400{
401 struct perf_data_file *file = &rec->file; 401 struct perf_data *data = &rec->data;
402 struct perf_session *session = rec->session; 402 struct perf_session *session = rec->session;
403 403
404 if (file->size == 0) 404 if (data->size == 0)
405 return 0; 405 return 0;
406 406
407 /* 407 /*
@@ -544,14 +544,14 @@ static void record__init_features(struct record *rec)
544static void 544static void
545record__finish_output(struct record *rec) 545record__finish_output(struct record *rec)
546{ 546{
547 struct perf_data_file *file = &rec->file; 547 struct perf_data *data = &rec->data;
548 int fd = perf_data_file__fd(file); 548 int fd = perf_data__fd(data);
549 549
550 if (file->is_pipe) 550 if (data->is_pipe)
551 return; 551 return;
552 552
553 rec->session->header.data_size += rec->bytes_written; 553 rec->session->header.data_size += rec->bytes_written;
554 file->size = lseek(perf_data_file__fd(file), 0, SEEK_CUR); 554 data->size = lseek(perf_data__fd(data), 0, SEEK_CUR);
555 555
556 if (!rec->no_buildid) { 556 if (!rec->no_buildid) {
557 process_buildids(rec); 557 process_buildids(rec);
@@ -590,7 +590,7 @@ static int record__synthesize(struct record *rec, bool tail);
590static int 590static int
591record__switch_output(struct record *rec, bool at_exit) 591record__switch_output(struct record *rec, bool at_exit)
592{ 592{
593 struct perf_data_file *file = &rec->file; 593 struct perf_data *data = &rec->data;
594 int fd, err; 594 int fd, err;
595 595
596 /* Same Size: "2015122520103046"*/ 596 /* Same Size: "2015122520103046"*/
@@ -608,7 +608,7 @@ record__switch_output(struct record *rec, bool at_exit)
608 return -EINVAL; 608 return -EINVAL;
609 } 609 }
610 610
611 fd = perf_data_file__switch(file, timestamp, 611 fd = perf_data__switch(data, timestamp,
612 rec->session->header.data_offset, 612 rec->session->header.data_offset,
613 at_exit); 613 at_exit);
614 if (fd >= 0 && !at_exit) { 614 if (fd >= 0 && !at_exit) {
@@ -618,7 +618,7 @@ record__switch_output(struct record *rec, bool at_exit)
618 618
619 if (!quiet) 619 if (!quiet)
620 fprintf(stderr, "[ perf record: Dump %s.%s ]\n", 620 fprintf(stderr, "[ perf record: Dump %s.%s ]\n",
621 file->path, timestamp); 621 data->path, timestamp);
622 622
623 /* Output tracking events */ 623 /* Output tracking events */
624 if (!at_exit) { 624 if (!at_exit) {
@@ -693,16 +693,16 @@ static int record__synthesize(struct record *rec, bool tail)
693{ 693{
694 struct perf_session *session = rec->session; 694 struct perf_session *session = rec->session;
695 struct machine *machine = &session->machines.host; 695 struct machine *machine = &session->machines.host;
696 struct perf_data_file *file = &rec->file; 696 struct perf_data *data = &rec->data;
697 struct record_opts *opts = &rec->opts; 697 struct record_opts *opts = &rec->opts;
698 struct perf_tool *tool = &rec->tool; 698 struct perf_tool *tool = &rec->tool;
699 int fd = perf_data_file__fd(file); 699 int fd = perf_data__fd(data);
700 int err = 0; 700 int err = 0;
701 701
702 if (rec->opts.tail_synthesize != tail) 702 if (rec->opts.tail_synthesize != tail)
703 return 0; 703 return 0;
704 704
705 if (file->is_pipe) { 705 if (data->is_pipe) {
706 err = perf_event__synthesize_features( 706 err = perf_event__synthesize_features(
707 tool, session, rec->evlist, process_synthesized_event); 707 tool, session, rec->evlist, process_synthesized_event);
708 if (err < 0) { 708 if (err < 0) {
@@ -781,7 +781,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
781 struct machine *machine; 781 struct machine *machine;
782 struct perf_tool *tool = &rec->tool; 782 struct perf_tool *tool = &rec->tool;
783 struct record_opts *opts = &rec->opts; 783 struct record_opts *opts = &rec->opts;
784 struct perf_data_file *file = &rec->file; 784 struct perf_data *data = &rec->data;
785 struct perf_session *session; 785 struct perf_session *session;
786 bool disabled = false, draining = false; 786 bool disabled = false, draining = false;
787 int fd; 787 int fd;
@@ -807,20 +807,20 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
807 signal(SIGUSR2, SIG_IGN); 807 signal(SIGUSR2, SIG_IGN);
808 } 808 }
809 809
810 session = perf_session__new(file, false, tool); 810 session = perf_session__new(data, false, tool);
811 if (session == NULL) { 811 if (session == NULL) {
812 pr_err("Perf session creation failed.\n"); 812 pr_err("Perf session creation failed.\n");
813 return -1; 813 return -1;
814 } 814 }
815 815
816 fd = perf_data_file__fd(file); 816 fd = perf_data__fd(data);
817 rec->session = session; 817 rec->session = session;
818 818
819 record__init_features(rec); 819 record__init_features(rec);
820 820
821 if (forks) { 821 if (forks) {
822 err = perf_evlist__prepare_workload(rec->evlist, &opts->target, 822 err = perf_evlist__prepare_workload(rec->evlist, &opts->target,
823 argv, file->is_pipe, 823 argv, data->is_pipe,
824 workload_exec_failed_signal); 824 workload_exec_failed_signal);
825 if (err < 0) { 825 if (err < 0) {
826 pr_err("Couldn't run the workload!\n"); 826 pr_err("Couldn't run the workload!\n");
@@ -856,7 +856,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
856 if (!rec->evlist->nr_groups) 856 if (!rec->evlist->nr_groups)
857 perf_header__clear_feat(&session->header, HEADER_GROUP_DESC); 857 perf_header__clear_feat(&session->header, HEADER_GROUP_DESC);
858 858
859 if (file->is_pipe) { 859 if (data->is_pipe) {
860 err = perf_header__write_pipe(fd); 860 err = perf_header__write_pipe(fd);
861 if (err < 0) 861 if (err < 0)
862 goto out_child; 862 goto out_child;
@@ -1117,8 +1117,8 @@ out_child:
1117 samples[0] = '\0'; 1117 samples[0] = '\0';
1118 1118
1119 fprintf(stderr, "[ perf record: Captured and wrote %.3f MB %s%s%s ]\n", 1119 fprintf(stderr, "[ perf record: Captured and wrote %.3f MB %s%s%s ]\n",
1120 perf_data_file__size(file) / 1024.0 / 1024.0, 1120 perf_data__size(data) / 1024.0 / 1024.0,
1121 file->path, postfix, samples); 1121 data->path, postfix, samples);
1122 } 1122 }
1123 1123
1124out_delete_session: 1124out_delete_session:
@@ -1482,7 +1482,7 @@ static struct option __record_options[] = {
1482 OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu", 1482 OPT_STRING('C', "cpu", &record.opts.target.cpu_list, "cpu",
1483 "list of cpus to monitor"), 1483 "list of cpus to monitor"),
1484 OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"), 1484 OPT_U64('c', "count", &record.opts.user_interval, "event period to sample"),
1485 OPT_STRING('o', "output", &record.file.path, "file", 1485 OPT_STRING('o', "output", &record.data.path, "file",
1486 "output file name"), 1486 "output file name"),
1487 OPT_BOOLEAN_SET('i', "no-inherit", &record.opts.no_inherit, 1487 OPT_BOOLEAN_SET('i', "no-inherit", &record.opts.no_inherit,
1488 &record.opts.no_inherit_set, 1488 &record.opts.no_inherit_set,
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index f9dff652dcbd..0dc323772b5e 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -257,7 +257,7 @@ static int report__setup_sample_type(struct report *rep)
257{ 257{
258 struct perf_session *session = rep->session; 258 struct perf_session *session = rep->session;
259 u64 sample_type = perf_evlist__combined_sample_type(session->evlist); 259 u64 sample_type = perf_evlist__combined_sample_type(session->evlist);
260 bool is_pipe = perf_data_file__is_pipe(session->file); 260 bool is_pipe = perf_data__is_pipe(session->data);
261 261
262 if (session->itrace_synth_opts->callchain || 262 if (session->itrace_synth_opts->callchain ||
263 (!is_pipe && 263 (!is_pipe &&
@@ -568,7 +568,7 @@ static int __cmd_report(struct report *rep)
568 int ret; 568 int ret;
569 struct perf_session *session = rep->session; 569 struct perf_session *session = rep->session;
570 struct perf_evsel *pos; 570 struct perf_evsel *pos;
571 struct perf_data_file *file = session->file; 571 struct perf_data *data = session->data;
572 572
573 signal(SIGINT, sig_handler); 573 signal(SIGINT, sig_handler);
574 574
@@ -637,7 +637,7 @@ static int __cmd_report(struct report *rep)
637 rep->nr_entries += evsel__hists(pos)->nr_entries; 637 rep->nr_entries += evsel__hists(pos)->nr_entries;
638 638
639 if (rep->nr_entries == 0) { 639 if (rep->nr_entries == 0) {
640 ui__error("The %s file has no samples!\n", file->path); 640 ui__error("The %s file has no samples!\n", data->path);
641 return 0; 641 return 0;
642 } 642 }
643 643
@@ -879,7 +879,7 @@ int cmd_report(int argc, const char **argv)
879 "Show inline function"), 879 "Show inline function"),
880 OPT_END() 880 OPT_END()
881 }; 881 };
882 struct perf_data_file file = { 882 struct perf_data data = {
883 .mode = PERF_DATA_MODE_READ, 883 .mode = PERF_DATA_MODE_READ,
884 }; 884 };
885 int ret = hists__init(); 885 int ret = hists__init();
@@ -940,11 +940,11 @@ int cmd_report(int argc, const char **argv)
940 input_name = "perf.data"; 940 input_name = "perf.data";
941 } 941 }
942 942
943 file.path = input_name; 943 data.path = input_name;
944 file.force = symbol_conf.force; 944 data.force = symbol_conf.force;
945 945
946repeat: 946repeat:
947 session = perf_session__new(&file, false, &report.tool); 947 session = perf_session__new(&data, false, &report.tool);
948 if (session == NULL) 948 if (session == NULL)
949 return -1; 949 return -1;
950 950
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index b7e8812ee80c..cb5410511f69 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1700,14 +1700,14 @@ static int perf_sched__read_events(struct perf_sched *sched)
1700 { "sched:sched_migrate_task", process_sched_migrate_task_event, }, 1700 { "sched:sched_migrate_task", process_sched_migrate_task_event, },
1701 }; 1701 };
1702 struct perf_session *session; 1702 struct perf_session *session;
1703 struct perf_data_file file = { 1703 struct perf_data data = {
1704 .path = input_name, 1704 .path = input_name,
1705 .mode = PERF_DATA_MODE_READ, 1705 .mode = PERF_DATA_MODE_READ,
1706 .force = sched->force, 1706 .force = sched->force,
1707 }; 1707 };
1708 int rc = -1; 1708 int rc = -1;
1709 1709
1710 session = perf_session__new(&file, false, &sched->tool); 1710 session = perf_session__new(&data, false, &sched->tool);
1711 if (session == NULL) { 1711 if (session == NULL) {
1712 pr_debug("No Memory for session\n"); 1712 pr_debug("No Memory for session\n");
1713 return -1; 1713 return -1;
@@ -2902,7 +2902,7 @@ static int perf_sched__timehist(struct perf_sched *sched)
2902 const struct perf_evsel_str_handler migrate_handlers[] = { 2902 const struct perf_evsel_str_handler migrate_handlers[] = {
2903 { "sched:sched_migrate_task", timehist_migrate_task_event, }, 2903 { "sched:sched_migrate_task", timehist_migrate_task_event, },
2904 }; 2904 };
2905 struct perf_data_file file = { 2905 struct perf_data data = {
2906 .path = input_name, 2906 .path = input_name,
2907 .mode = PERF_DATA_MODE_READ, 2907 .mode = PERF_DATA_MODE_READ,
2908 .force = sched->force, 2908 .force = sched->force,
@@ -2930,7 +2930,7 @@ static int perf_sched__timehist(struct perf_sched *sched)
2930 2930
2931 symbol_conf.use_callchain = sched->show_callchain; 2931 symbol_conf.use_callchain = sched->show_callchain;
2932 2932
2933 session = perf_session__new(&file, false, &sched->tool); 2933 session = perf_session__new(&data, false, &sched->tool);
2934 if (session == NULL) 2934 if (session == NULL)
2935 return -ENOMEM; 2935 return -ENOMEM;
2936 2936
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 4d198f73b29a..8f8fa952b506 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -217,12 +217,12 @@ struct perf_evsel_script {
217}; 217};
218 218
219static struct perf_evsel_script *perf_evsel_script__new(struct perf_evsel *evsel, 219static struct perf_evsel_script *perf_evsel_script__new(struct perf_evsel *evsel,
220 struct perf_data_file *file) 220 struct perf_data *data)
221{ 221{
222 struct perf_evsel_script *es = malloc(sizeof(*es)); 222 struct perf_evsel_script *es = malloc(sizeof(*es));
223 223
224 if (es != NULL) { 224 if (es != NULL) {
225 if (asprintf(&es->filename, "%s.%s.dump", file->path, perf_evsel__name(evsel)) < 0) 225 if (asprintf(&es->filename, "%s.%s.dump", data->path, perf_evsel__name(evsel)) < 0)
226 goto out_free; 226 goto out_free;
227 es->fp = fopen(es->filename, "w"); 227 es->fp = fopen(es->filename, "w");
228 if (es->fp == NULL) 228 if (es->fp == NULL)
@@ -1954,7 +1954,7 @@ static int perf_script__fopen_per_event_dump(struct perf_script *script)
1954 struct perf_evsel *evsel; 1954 struct perf_evsel *evsel;
1955 1955
1956 evlist__for_each_entry(script->session->evlist, evsel) { 1956 evlist__for_each_entry(script->session->evlist, evsel) {
1957 evsel->priv = perf_evsel_script__new(evsel, script->session->file); 1957 evsel->priv = perf_evsel_script__new(evsel, script->session->data);
1958 if (evsel->priv == NULL) 1958 if (evsel->priv == NULL)
1959 goto out_err_fclose; 1959 goto out_err_fclose;
1960 } 1960 }
@@ -2590,14 +2590,14 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
2590 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN]; 2590 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN];
2591 DIR *scripts_dir, *lang_dir; 2591 DIR *scripts_dir, *lang_dir;
2592 struct perf_session *session; 2592 struct perf_session *session;
2593 struct perf_data_file file = { 2593 struct perf_data data = {
2594 .path = input_name, 2594 .path = input_name,
2595 .mode = PERF_DATA_MODE_READ, 2595 .mode = PERF_DATA_MODE_READ,
2596 }; 2596 };
2597 char *temp; 2597 char *temp;
2598 int i = 0; 2598 int i = 0;
2599 2599
2600 session = perf_session__new(&file, false, NULL); 2600 session = perf_session__new(&data, false, NULL);
2601 if (!session) 2601 if (!session)
2602 return -1; 2602 return -1;
2603 2603
@@ -2875,7 +2875,7 @@ int cmd_script(int argc, const char **argv)
2875 .ordering_requires_timestamps = true, 2875 .ordering_requires_timestamps = true,
2876 }, 2876 },
2877 }; 2877 };
2878 struct perf_data_file file = { 2878 struct perf_data data = {
2879 .mode = PERF_DATA_MODE_READ, 2879 .mode = PERF_DATA_MODE_READ,
2880 }; 2880 };
2881 const struct option options[] = { 2881 const struct option options[] = {
@@ -2982,8 +2982,8 @@ int cmd_script(int argc, const char **argv)
2982 argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage, 2982 argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
2983 PARSE_OPT_STOP_AT_NON_OPTION); 2983 PARSE_OPT_STOP_AT_NON_OPTION);
2984 2984
2985 file.path = input_name; 2985 data.path = input_name;
2986 file.force = symbol_conf.force; 2986 data.force = symbol_conf.force;
2987 2987
2988 if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) { 2988 if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) {
2989 rec_script_path = get_script_path(argv[1], RECORD_SUFFIX); 2989 rec_script_path = get_script_path(argv[1], RECORD_SUFFIX);
@@ -3150,7 +3150,7 @@ int cmd_script(int argc, const char **argv)
3150 if (!script_name) 3150 if (!script_name)
3151 setup_pager(); 3151 setup_pager();
3152 3152
3153 session = perf_session__new(&file, false, &script.tool); 3153 session = perf_session__new(&data, false, &script.tool);
3154 if (session == NULL) 3154 if (session == NULL)
3155 return -1; 3155 return -1;
3156 3156
@@ -3206,7 +3206,7 @@ int cmd_script(int argc, const char **argv)
3206 goto out_delete; 3206 goto out_delete;
3207 } 3207 }
3208 3208
3209 input = open(file.path, O_RDONLY); /* input_name */ 3209 input = open(data.path, O_RDONLY); /* input_name */
3210 if (input < 0) { 3210 if (input < 0) {
3211 err = -errno; 3211 err = -errno;
3212 perror("failed to open file"); 3212 perror("failed to open file");
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 988bdfa5d832..85af6d291c06 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -175,7 +175,7 @@ static int print_free_counters_hint;
175 175
176struct perf_stat { 176struct perf_stat {
177 bool record; 177 bool record;
178 struct perf_data_file file; 178 struct perf_data data;
179 struct perf_session *session; 179 struct perf_session *session;
180 u64 bytes_written; 180 u64 bytes_written;
181 struct perf_tool tool; 181 struct perf_tool tool;
@@ -253,7 +253,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel)
253 * by attr->sample_type != 0, and we can't run it on 253 * by attr->sample_type != 0, and we can't run it on
254 * stat sessions. 254 * stat sessions.
255 */ 255 */
256 if (!(STAT_RECORD && perf_stat.file.is_pipe)) 256 if (!(STAT_RECORD && perf_stat.data.is_pipe))
257 attr->sample_type = PERF_SAMPLE_IDENTIFIER; 257 attr->sample_type = PERF_SAMPLE_IDENTIFIER;
258 258
259 /* 259 /*
@@ -295,7 +295,7 @@ static int process_synthesized_event(struct perf_tool *tool __maybe_unused,
295 struct perf_sample *sample __maybe_unused, 295 struct perf_sample *sample __maybe_unused,
296 struct machine *machine __maybe_unused) 296 struct machine *machine __maybe_unused)
297{ 297{
298 if (perf_data_file__write(&perf_stat.file, event, event->header.size) < 0) { 298 if (perf_data__write(&perf_stat.data, event, event->header.size) < 0) {
299 pr_err("failed to write perf data, error: %m\n"); 299 pr_err("failed to write perf data, error: %m\n");
300 return -1; 300 return -1;
301 } 301 }
@@ -628,7 +628,7 @@ static int __run_perf_stat(int argc, const char **argv)
628 size_t l; 628 size_t l;
629 int status = 0; 629 int status = 0;
630 const bool forks = (argc > 0); 630 const bool forks = (argc > 0);
631 bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false; 631 bool is_pipe = STAT_RECORD ? perf_stat.data.is_pipe : false;
632 struct perf_evsel_config_term *err_term; 632 struct perf_evsel_config_term *err_term;
633 633
634 if (interval) { 634 if (interval) {
@@ -719,10 +719,10 @@ try_again:
719 } 719 }
720 720
721 if (STAT_RECORD) { 721 if (STAT_RECORD) {
722 int err, fd = perf_data_file__fd(&perf_stat.file); 722 int err, fd = perf_data__fd(&perf_stat.data);
723 723
724 if (is_pipe) { 724 if (is_pipe) {
725 err = perf_header__write_pipe(perf_data_file__fd(&perf_stat.file)); 725 err = perf_header__write_pipe(perf_data__fd(&perf_stat.data));
726 } else { 726 } else {
727 err = perf_session__write_header(perf_stat.session, evsel_list, 727 err = perf_session__write_header(perf_stat.session, evsel_list,
728 fd, false); 728 fd, false);
@@ -1696,7 +1696,7 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
1696 char buf[64], *prefix = NULL; 1696 char buf[64], *prefix = NULL;
1697 1697
1698 /* Do not print anything if we record to the pipe. */ 1698 /* Do not print anything if we record to the pipe. */
1699 if (STAT_RECORD && perf_stat.file.is_pipe) 1699 if (STAT_RECORD && perf_stat.data.is_pipe)
1700 return; 1700 return;
1701 1701
1702 if (interval) 1702 if (interval)
@@ -2406,20 +2406,20 @@ static void init_features(struct perf_session *session)
2406static int __cmd_record(int argc, const char **argv) 2406static int __cmd_record(int argc, const char **argv)
2407{ 2407{
2408 struct perf_session *session; 2408 struct perf_session *session;
2409 struct perf_data_file *file = &perf_stat.file; 2409 struct perf_data *data = &perf_stat.data;
2410 2410
2411 argc = parse_options(argc, argv, stat_options, stat_record_usage, 2411 argc = parse_options(argc, argv, stat_options, stat_record_usage,
2412 PARSE_OPT_STOP_AT_NON_OPTION); 2412 PARSE_OPT_STOP_AT_NON_OPTION);
2413 2413
2414 if (output_name) 2414 if (output_name)
2415 file->path = output_name; 2415 data->path = output_name;
2416 2416
2417 if (run_count != 1 || forever) { 2417 if (run_count != 1 || forever) {
2418 pr_err("Cannot use -r option with perf stat record.\n"); 2418 pr_err("Cannot use -r option with perf stat record.\n");
2419 return -1; 2419 return -1;
2420 } 2420 }
2421 2421
2422 session = perf_session__new(file, false, NULL); 2422 session = perf_session__new(data, false, NULL);
2423 if (session == NULL) { 2423 if (session == NULL) {
2424 pr_err("Perf session creation failed.\n"); 2424 pr_err("Perf session creation failed.\n");
2425 return -1; 2425 return -1;
@@ -2477,7 +2477,7 @@ int process_stat_config_event(struct perf_tool *tool,
2477 if (st->aggr_mode != AGGR_UNSET) 2477 if (st->aggr_mode != AGGR_UNSET)
2478 stat_config.aggr_mode = st->aggr_mode; 2478 stat_config.aggr_mode = st->aggr_mode;
2479 2479
2480 if (perf_stat.file.is_pipe) 2480 if (perf_stat.data.is_pipe)
2481 perf_stat_init_aggr_mode(); 2481 perf_stat_init_aggr_mode();
2482 else 2482 else
2483 perf_stat_init_aggr_mode_file(st); 2483 perf_stat_init_aggr_mode_file(st);
@@ -2585,10 +2585,10 @@ static int __cmd_report(int argc, const char **argv)
2585 input_name = "perf.data"; 2585 input_name = "perf.data";
2586 } 2586 }
2587 2587
2588 perf_stat.file.path = input_name; 2588 perf_stat.data.path = input_name;
2589 perf_stat.file.mode = PERF_DATA_MODE_READ; 2589 perf_stat.data.mode = PERF_DATA_MODE_READ;
2590 2590
2591 session = perf_session__new(&perf_stat.file, false, &perf_stat.tool); 2591 session = perf_session__new(&perf_stat.data, false, &perf_stat.tool);
2592 if (session == NULL) 2592 if (session == NULL)
2593 return -1; 2593 return -1;
2594 2594
@@ -2859,7 +2859,7 @@ int cmd_stat(int argc, const char **argv)
2859 * records, but the need to suppress the kptr_restrict messages in older 2859 * records, but the need to suppress the kptr_restrict messages in older
2860 * tools remain -acme 2860 * tools remain -acme
2861 */ 2861 */
2862 int fd = perf_data_file__fd(&perf_stat.file); 2862 int fd = perf_data__fd(&perf_stat.data);
2863 int err = perf_event__synthesize_kernel_mmap((void *)&perf_stat, 2863 int err = perf_event__synthesize_kernel_mmap((void *)&perf_stat,
2864 process_synthesized_event, 2864 process_synthesized_event,
2865 &perf_stat.session->machines.host); 2865 &perf_stat.session->machines.host);
@@ -2873,7 +2873,7 @@ int cmd_stat(int argc, const char **argv)
2873 pr_err("failed to write stat round event\n"); 2873 pr_err("failed to write stat round event\n");
2874 } 2874 }
2875 2875
2876 if (!perf_stat.file.is_pipe) { 2876 if (!perf_stat.data.is_pipe) {
2877 perf_stat.session->header.data_size += perf_stat.bytes_written; 2877 perf_stat.session->header.data_size += perf_stat.bytes_written;
2878 perf_session__write_header(perf_stat.session, evsel_list, fd, true); 2878 perf_session__write_header(perf_stat.session, evsel_list, fd, true);
2879 } 2879 }
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 01de01ca14f2..0f79ea5e2f0f 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1601,13 +1601,13 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1601 { "syscalls:sys_exit_pselect6", process_exit_poll }, 1601 { "syscalls:sys_exit_pselect6", process_exit_poll },
1602 { "syscalls:sys_exit_select", process_exit_poll }, 1602 { "syscalls:sys_exit_select", process_exit_poll },
1603 }; 1603 };
1604 struct perf_data_file file = { 1604 struct perf_data data = {
1605 .path = input_name, 1605 .path = input_name,
1606 .mode = PERF_DATA_MODE_READ, 1606 .mode = PERF_DATA_MODE_READ,
1607 .force = tchart->force, 1607 .force = tchart->force,
1608 }; 1608 };
1609 1609
1610 struct perf_session *session = perf_session__new(&file, false, 1610 struct perf_session *session = perf_session__new(&data, false,
1611 &tchart->tool); 1611 &tchart->tool);
1612 int ret = -EINVAL; 1612 int ret = -EINVAL;
1613 1613
@@ -1617,7 +1617,7 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
1617 symbol__init(&session->header.env); 1617 symbol__init(&session->header.env);
1618 1618
1619 (void)perf_header__process_sections(&session->header, 1619 (void)perf_header__process_sections(&session->header,
1620 perf_data_file__fd(session->file), 1620 perf_data__fd(session->data),
1621 tchart, 1621 tchart,
1622 process_header); 1622 process_header);
1623 1623
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 78855916f4b0..7def6947ad61 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2532,7 +2532,7 @@ static int trace__replay(struct trace *trace)
2532 const struct perf_evsel_str_handler handlers[] = { 2532 const struct perf_evsel_str_handler handlers[] = {
2533 { "probe:vfs_getname", trace__vfs_getname, }, 2533 { "probe:vfs_getname", trace__vfs_getname, },
2534 }; 2534 };
2535 struct perf_data_file file = { 2535 struct perf_data data = {
2536 .path = input_name, 2536 .path = input_name,
2537 .mode = PERF_DATA_MODE_READ, 2537 .mode = PERF_DATA_MODE_READ,
2538 .force = trace->force, 2538 .force = trace->force,
@@ -2558,7 +2558,7 @@ static int trace__replay(struct trace *trace)
2558 /* add tid to output */ 2558 /* add tid to output */
2559 trace->multiple_threads = true; 2559 trace->multiple_threads = true;
2560 2560
2561 session = perf_session__new(&file, false, &trace->tool); 2561 session = perf_session__new(&data, false, &trace->tool);
2562 if (session == NULL) 2562 if (session == NULL)
2563 return -1; 2563 return -1;
2564 2564
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index 19b0561fd6f6..7536782e8495 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -29,12 +29,12 @@ static int get_temp(char *path)
29static int session_write_header(char *path) 29static int session_write_header(char *path)
30{ 30{
31 struct perf_session *session; 31 struct perf_session *session;
32 struct perf_data_file file = { 32 struct perf_data data = {
33 .path = path, 33 .path = path,
34 .mode = PERF_DATA_MODE_WRITE, 34 .mode = PERF_DATA_MODE_WRITE,
35 }; 35 };
36 36
37 session = perf_session__new(&file, false, NULL); 37 session = perf_session__new(&data, false, NULL);
38 TEST_ASSERT_VAL("can't get session", session); 38 TEST_ASSERT_VAL("can't get session", session);
39 39
40 session->evlist = perf_evlist__new_default(); 40 session->evlist = perf_evlist__new_default();
@@ -46,7 +46,7 @@ static int session_write_header(char *path)
46 session->header.data_size += DATA_SIZE; 46 session->header.data_size += DATA_SIZE;
47 47
48 TEST_ASSERT_VAL("failed to write header", 48 TEST_ASSERT_VAL("failed to write header",
49 !perf_session__write_header(session, session->evlist, file.fd, true)); 49 !perf_session__write_header(session, session->evlist, data.fd, true));
50 50
51 perf_session__delete(session); 51 perf_session__delete(session);
52 52
@@ -56,13 +56,13 @@ static int session_write_header(char *path)
56static int check_cpu_topology(char *path, struct cpu_map *map) 56static int check_cpu_topology(char *path, struct cpu_map *map)
57{ 57{
58 struct perf_session *session; 58 struct perf_session *session;
59 struct perf_data_file file = { 59 struct perf_data data = {
60 .path = path, 60 .path = path,
61 .mode = PERF_DATA_MODE_READ, 61 .mode = PERF_DATA_MODE_READ,
62 }; 62 };
63 int i; 63 int i;
64 64
65 session = perf_session__new(&file, false, NULL); 65 session = perf_session__new(&data, false, NULL);
66 TEST_ASSERT_VAL("can't get session", session); 66 TEST_ASSERT_VAL("can't get session", session);
67 67
68 for (i = 0; i < session->header.env.nr_cpus_avail; i++) { 68 for (i = 0; i < session->header.env.nr_cpus_avail; i++) {
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 5547457566a7..a33491416400 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -208,7 +208,7 @@ static int auxtrace_queues__grow(struct auxtrace_queues *queues,
208 208
209static void *auxtrace_copy_data(u64 size, struct perf_session *session) 209static void *auxtrace_copy_data(u64 size, struct perf_session *session)
210{ 210{
211 int fd = perf_data_file__fd(session->file); 211 int fd = perf_data__fd(session->data);
212 void *p; 212 void *p;
213 ssize_t ret; 213 ssize_t ret;
214 214
@@ -305,7 +305,7 @@ static int auxtrace_queues__add_event_buffer(struct auxtrace_queues *queues,
305 if (session->one_mmap) { 305 if (session->one_mmap) {
306 buffer->data = buffer->data_offset - session->one_mmap_offset + 306 buffer->data = buffer->data_offset - session->one_mmap_offset +
307 session->one_mmap_addr; 307 session->one_mmap_addr;
308 } else if (perf_data_file__is_pipe(session->file)) { 308 } else if (perf_data__is_pipe(session->data)) {
309 buffer->data = auxtrace_copy_data(buffer->size, session); 309 buffer->data = auxtrace_copy_data(buffer->size, session);
310 if (!buffer->data) 310 if (!buffer->data)
311 return -ENOMEM; 311 return -ENOMEM;
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 2346cecb8ea2..9fdae383a58c 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -1577,7 +1577,7 @@ int bt_convert__perf2ctf(const char *input, const char *path,
1577 struct perf_data_convert_opts *opts) 1577 struct perf_data_convert_opts *opts)
1578{ 1578{
1579 struct perf_session *session; 1579 struct perf_session *session;
1580 struct perf_data_file file = { 1580 struct perf_data data = {
1581 .path = input, 1581 .path = input,
1582 .mode = PERF_DATA_MODE_READ, 1582 .mode = PERF_DATA_MODE_READ,
1583 .force = opts->force, 1583 .force = opts->force,
@@ -1619,7 +1619,7 @@ int bt_convert__perf2ctf(const char *input, const char *path,
1619 1619
1620 err = -1; 1620 err = -1;
1621 /* perf.data session */ 1621 /* perf.data session */
1622 session = perf_session__new(&file, 0, &c.tool); 1622 session = perf_session__new(&data, 0, &c.tool);
1623 if (!session) 1623 if (!session)
1624 goto free_writer; 1624 goto free_writer;
1625 1625
@@ -1650,7 +1650,7 @@ int bt_convert__perf2ctf(const char *input, const char *path,
1650 1650
1651 fprintf(stderr, 1651 fprintf(stderr,
1652 "[ perf data convert: Converted '%s' into CTF data '%s' ]\n", 1652 "[ perf data convert: Converted '%s' into CTF data '%s' ]\n",
1653 file.path, path); 1653 data.path, path);
1654 1654
1655 fprintf(stderr, 1655 fprintf(stderr,
1656 "[ perf data convert: Converted and wrote %.3f MB (%" PRIu64 " samples", 1656 "[ perf data convert: Converted and wrote %.3f MB (%" PRIu64 " samples",
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 1123b30e3033..a6eea3df4c10 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -21,56 +21,56 @@
21#endif 21#endif
22#endif 22#endif
23 23
24static bool check_pipe(struct perf_data_file *file) 24static bool check_pipe(struct perf_data *data)
25{ 25{
26 struct stat st; 26 struct stat st;
27 bool is_pipe = false; 27 bool is_pipe = false;
28 int fd = perf_data_file__is_read(file) ? 28 int fd = perf_data__is_read(data) ?
29 STDIN_FILENO : STDOUT_FILENO; 29 STDIN_FILENO : STDOUT_FILENO;
30 30
31 if (!file->path) { 31 if (!data->path) {
32 if (!fstat(fd, &st) && S_ISFIFO(st.st_mode)) 32 if (!fstat(fd, &st) && S_ISFIFO(st.st_mode))
33 is_pipe = true; 33 is_pipe = true;
34 } else { 34 } else {
35 if (!strcmp(file->path, "-")) 35 if (!strcmp(data->path, "-"))
36 is_pipe = true; 36 is_pipe = true;
37 } 37 }
38 38
39 if (is_pipe) 39 if (is_pipe)
40 file->fd = fd; 40 data->fd = fd;
41 41
42 return file->is_pipe = is_pipe; 42 return data->is_pipe = is_pipe;
43} 43}
44 44
45static int check_backup(struct perf_data_file *file) 45static int check_backup(struct perf_data *data)
46{ 46{
47 struct stat st; 47 struct stat st;
48 48
49 if (!stat(file->path, &st) && st.st_size) { 49 if (!stat(data->path, &st) && st.st_size) {
50 /* TODO check errors properly */ 50 /* TODO check errors properly */
51 char oldname[PATH_MAX]; 51 char oldname[PATH_MAX];
52 snprintf(oldname, sizeof(oldname), "%s.old", 52 snprintf(oldname, sizeof(oldname), "%s.old",
53 file->path); 53 data->path);
54 unlink(oldname); 54 unlink(oldname);
55 rename(file->path, oldname); 55 rename(data->path, oldname);
56 } 56 }
57 57
58 return 0; 58 return 0;
59} 59}
60 60
61static int open_file_read(struct perf_data_file *file) 61static int open_file_read(struct perf_data *data)
62{ 62{
63 struct stat st; 63 struct stat st;
64 int fd; 64 int fd;
65 char sbuf[STRERR_BUFSIZE]; 65 char sbuf[STRERR_BUFSIZE];
66 66
67 fd = open(file->path, O_RDONLY); 67 fd = open(data->path, O_RDONLY);
68 if (fd < 0) { 68 if (fd < 0) {
69 int err = errno; 69 int err = errno;
70 70
71 pr_err("failed to open %s: %s", file->path, 71 pr_err("failed to open %s: %s", data->path,
72 str_error_r(err, sbuf, sizeof(sbuf))); 72 str_error_r(err, sbuf, sizeof(sbuf)));
73 if (err == ENOENT && !strcmp(file->path, "perf.data")) 73 if (err == ENOENT && !strcmp(data->path, "perf.data"))
74 pr_err(" (try 'perf record' first)"); 74 pr_err(" (try 'perf record' first)");
75 pr_err("\n"); 75 pr_err("\n");
76 return -err; 76 return -err;
@@ -79,19 +79,19 @@ static int open_file_read(struct perf_data_file *file)
79 if (fstat(fd, &st) < 0) 79 if (fstat(fd, &st) < 0)
80 goto out_close; 80 goto out_close;
81 81
82 if (!file->force && st.st_uid && (st.st_uid != geteuid())) { 82 if (!data->force && st.st_uid && (st.st_uid != geteuid())) {
83 pr_err("File %s not owned by current user or root (use -f to override)\n", 83 pr_err("File %s not owned by current user or root (use -f to override)\n",
84 file->path); 84 data->path);
85 goto out_close; 85 goto out_close;
86 } 86 }
87 87
88 if (!st.st_size) { 88 if (!st.st_size) {
89 pr_info("zero-sized file (%s), nothing to do!\n", 89 pr_info("zero-sized data (%s), nothing to do!\n",
90 file->path); 90 data->path);
91 goto out_close; 91 goto out_close;
92 } 92 }
93 93
94 file->size = st.st_size; 94 data->size = st.st_size;
95 return fd; 95 return fd;
96 96
97 out_close: 97 out_close:
@@ -99,93 +99,93 @@ static int open_file_read(struct perf_data_file *file)
99 return -1; 99 return -1;
100} 100}
101 101
102static int open_file_write(struct perf_data_file *file) 102static int open_file_write(struct perf_data *data)
103{ 103{
104 int fd; 104 int fd;
105 char sbuf[STRERR_BUFSIZE]; 105 char sbuf[STRERR_BUFSIZE];
106 106
107 if (check_backup(file)) 107 if (check_backup(data))
108 return -1; 108 return -1;
109 109
110 fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 110 fd = open(data->path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC,
111 S_IRUSR|S_IWUSR); 111 S_IRUSR|S_IWUSR);
112 112
113 if (fd < 0) 113 if (fd < 0)
114 pr_err("failed to open %s : %s\n", file->path, 114 pr_err("failed to open %s : %s\n", data->path,
115 str_error_r(errno, sbuf, sizeof(sbuf))); 115 str_error_r(errno, sbuf, sizeof(sbuf)));
116 116
117 return fd; 117 return fd;
118} 118}
119 119
120static int open_file(struct perf_data_file *file) 120static int open_file(struct perf_data *data)
121{ 121{
122 int fd; 122 int fd;
123 123
124 fd = perf_data_file__is_read(file) ? 124 fd = perf_data__is_read(data) ?
125 open_file_read(file) : open_file_write(file); 125 open_file_read(data) : open_file_write(data);
126 126
127 file->fd = fd; 127 data->fd = fd;
128 return fd < 0 ? -1 : 0; 128 return fd < 0 ? -1 : 0;
129} 129}
130 130
131int perf_data_file__open(struct perf_data_file *file) 131int perf_data__open(struct perf_data *data)
132{ 132{
133 if (check_pipe(file)) 133 if (check_pipe(data))
134 return 0; 134 return 0;
135 135
136 if (!file->path) 136 if (!data->path)
137 file->path = "perf.data"; 137 data->path = "perf.data";
138 138
139 return open_file(file); 139 return open_file(data);
140} 140}
141 141
142void perf_data_file__close(struct perf_data_file *file) 142void perf_data__close(struct perf_data *data)
143{ 143{
144 close(file->fd); 144 close(data->fd);
145} 145}
146 146
147ssize_t perf_data_file__write(struct perf_data_file *file, 147ssize_t perf_data__write(struct perf_data *data,
148 void *buf, size_t size) 148 void *buf, size_t size)
149{ 149{
150 return writen(file->fd, buf, size); 150 return writen(data->fd, buf, size);
151} 151}
152 152
153int perf_data_file__switch(struct perf_data_file *file, 153int perf_data__switch(struct perf_data *data,
154 const char *postfix, 154 const char *postfix,
155 size_t pos, bool at_exit) 155 size_t pos, bool at_exit)
156{ 156{
157 char *new_filepath; 157 char *new_filepath;
158 int ret; 158 int ret;
159 159
160 if (check_pipe(file)) 160 if (check_pipe(data))
161 return -EINVAL; 161 return -EINVAL;
162 if (perf_data_file__is_read(file)) 162 if (perf_data__is_read(data))
163 return -EINVAL; 163 return -EINVAL;
164 164
165 if (asprintf(&new_filepath, "%s.%s", file->path, postfix) < 0) 165 if (asprintf(&new_filepath, "%s.%s", data->path, postfix) < 0)
166 return -ENOMEM; 166 return -ENOMEM;
167 167
168 /* 168 /*
169 * Only fire a warning, don't return error, continue fill 169 * Only fire a warning, don't return error, continue fill
170 * original file. 170 * original file.
171 */ 171 */
172 if (rename(file->path, new_filepath)) 172 if (rename(data->path, new_filepath))
173 pr_warning("Failed to rename %s to %s\n", file->path, new_filepath); 173 pr_warning("Failed to rename %s to %s\n", data->path, new_filepath);
174 174
175 if (!at_exit) { 175 if (!at_exit) {
176 close(file->fd); 176 close(data->fd);
177 ret = perf_data_file__open(file); 177 ret = perf_data__open(data);
178 if (ret < 0) 178 if (ret < 0)
179 goto out; 179 goto out;
180 180
181 if (lseek(file->fd, pos, SEEK_SET) == (off_t)-1) { 181 if (lseek(data->fd, pos, SEEK_SET) == (off_t)-1) {
182 ret = -errno; 182 ret = -errno;
183 pr_debug("Failed to lseek to %zu: %s", 183 pr_debug("Failed to lseek to %zu: %s",
184 pos, strerror(errno)); 184 pos, strerror(errno));
185 goto out; 185 goto out;
186 } 186 }
187 } 187 }
188 ret = file->fd; 188 ret = data->fd;
189out: 189out:
190 free(new_filepath); 190 free(new_filepath);
191 return ret; 191 return ret;
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h
index ae510ce16cb1..a1f9d70426b1 100644
--- a/tools/perf/util/data.h
+++ b/tools/perf/util/data.h
@@ -8,7 +8,7 @@ enum perf_data_mode {
8 PERF_DATA_MODE_READ, 8 PERF_DATA_MODE_READ,
9}; 9};
10 10
11struct perf_data_file { 11struct perf_data {
12 const char *path; 12 const char *path;
13 int fd; 13 int fd;
14 bool is_pipe; 14 bool is_pipe;
@@ -17,43 +17,43 @@ struct perf_data_file {
17 enum perf_data_mode mode; 17 enum perf_data_mode mode;
18}; 18};
19 19
20static inline bool perf_data_file__is_read(struct perf_data_file *file) 20static inline bool perf_data__is_read(struct perf_data *data)
21{ 21{
22 return file->mode == PERF_DATA_MODE_READ; 22 return data->mode == PERF_DATA_MODE_READ;
23} 23}
24 24
25static inline bool perf_data_file__is_write(struct perf_data_file *file) 25static inline bool perf_data__is_write(struct perf_data *data)
26{ 26{
27 return file->mode == PERF_DATA_MODE_WRITE; 27 return data->mode == PERF_DATA_MODE_WRITE;
28} 28}
29 29
30static inline int perf_data_file__is_pipe(struct perf_data_file *file) 30static inline int perf_data__is_pipe(struct perf_data *data)
31{ 31{
32 return file->is_pipe; 32 return data->is_pipe;
33} 33}
34 34
35static inline int perf_data_file__fd(struct perf_data_file *file) 35static inline int perf_data__fd(struct perf_data *data)
36{ 36{
37 return file->fd; 37 return data->fd;
38} 38}
39 39
40static inline unsigned long perf_data_file__size(struct perf_data_file *file) 40static inline unsigned long perf_data__size(struct perf_data *data)
41{ 41{
42 return file->size; 42 return data->size;
43} 43}
44 44
45int perf_data_file__open(struct perf_data_file *file); 45int perf_data__open(struct perf_data *data);
46void perf_data_file__close(struct perf_data_file *file); 46void perf_data__close(struct perf_data *data);
47ssize_t perf_data_file__write(struct perf_data_file *file, 47ssize_t perf_data__write(struct perf_data *data,
48 void *buf, size_t size); 48 void *buf, size_t size);
49/* 49/*
50 * If at_exit is set, only rename current perf.data to 50 * If at_exit is set, only rename current perf.data to
51 * perf.data.<postfix>, continue write on original file. 51 * perf.data.<postfix>, continue write on original data.
52 * Set at_exit when flushing the last output. 52 * Set at_exit when flushing the last output.
53 * 53 *
54 * Return value is fd of new output. 54 * Return value is fd of new output.
55 */ 55 */
56int perf_data_file__switch(struct perf_data_file *file, 56int perf_data__switch(struct perf_data *data,
57 const char *postfix, 57 const char *postfix,
58 size_t pos, bool at_exit); 58 size_t pos, bool at_exit);
59#endif /* __PERF_DATA_H */ 59#endif /* __PERF_DATA_H */
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 605bbd5404fb..d7be552b21c8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1762,7 +1762,7 @@ process_event_desc(struct feat_fd *ff, void *data __maybe_unused)
1762 1762
1763 session = container_of(ff->ph, struct perf_session, header); 1763 session = container_of(ff->ph, struct perf_session, header);
1764 1764
1765 if (session->file->is_pipe) { 1765 if (session->data->is_pipe) {
1766 /* Save events for reading later by print_event_desc, 1766 /* Save events for reading later by print_event_desc,
1767 * since they can't be read again in pipe mode. */ 1767 * since they can't be read again in pipe mode. */
1768 ff->events = events; 1768 ff->events = events;
@@ -1771,7 +1771,7 @@ process_event_desc(struct feat_fd *ff, void *data __maybe_unused)
1771 for (evsel = events; evsel->attr.size; evsel++) 1771 for (evsel = events; evsel->attr.size; evsel++)
1772 perf_evlist__set_event_name(session->evlist, evsel); 1772 perf_evlist__set_event_name(session->evlist, evsel);
1773 1773
1774 if (!session->file->is_pipe) 1774 if (!session->data->is_pipe)
1775 free_event_desc(events); 1775 free_event_desc(events);
1776 1776
1777 return 0; 1777 return 0;
@@ -2248,7 +2248,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
2248{ 2248{
2249 struct header_print_data hd; 2249 struct header_print_data hd;
2250 struct perf_header *header = &session->header; 2250 struct perf_header *header = &session->header;
2251 int fd = perf_data_file__fd(session->file); 2251 int fd = perf_data__fd(session->data);
2252 struct stat st; 2252 struct stat st;
2253 int ret, bit; 2253 int ret, bit;
2254 2254
@@ -2264,7 +2264,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full)
2264 perf_header__process_sections(header, fd, &hd, 2264 perf_header__process_sections(header, fd, &hd,
2265 perf_file_section__fprintf_info); 2265 perf_file_section__fprintf_info);
2266 2266
2267 if (session->file->is_pipe) 2267 if (session->data->is_pipe)
2268 return 0; 2268 return 0;
2269 2269
2270 fprintf(fp, "# missing features: "); 2270 fprintf(fp, "# missing features: ");
@@ -2757,7 +2757,7 @@ static int perf_header__read_pipe(struct perf_session *session)
2757 struct perf_pipe_file_header f_header; 2757 struct perf_pipe_file_header f_header;
2758 2758
2759 if (perf_file_header__read_pipe(&f_header, header, 2759 if (perf_file_header__read_pipe(&f_header, header,
2760 perf_data_file__fd(session->file), 2760 perf_data__fd(session->data),
2761 session->repipe) < 0) { 2761 session->repipe) < 0) {
2762 pr_debug("incompatible file format\n"); 2762 pr_debug("incompatible file format\n");
2763 return -EINVAL; 2763 return -EINVAL;
@@ -2860,13 +2860,13 @@ static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist,
2860 2860
2861int perf_session__read_header(struct perf_session *session) 2861int perf_session__read_header(struct perf_session *session)
2862{ 2862{
2863 struct perf_data_file *file = session->file; 2863 struct perf_data *data = session->data;
2864 struct perf_header *header = &session->header; 2864 struct perf_header *header = &session->header;
2865 struct perf_file_header f_header; 2865 struct perf_file_header f_header;
2866 struct perf_file_attr f_attr; 2866 struct perf_file_attr f_attr;
2867 u64 f_id; 2867 u64 f_id;
2868 int nr_attrs, nr_ids, i, j; 2868 int nr_attrs, nr_ids, i, j;
2869 int fd = perf_data_file__fd(file); 2869 int fd = perf_data__fd(data);
2870 2870
2871 session->evlist = perf_evlist__new(); 2871 session->evlist = perf_evlist__new();
2872 if (session->evlist == NULL) 2872 if (session->evlist == NULL)
@@ -2874,7 +2874,7 @@ int perf_session__read_header(struct perf_session *session)
2874 2874
2875 session->evlist->env = &header->env; 2875 session->evlist->env = &header->env;
2876 session->machines.host.env = &header->env; 2876 session->machines.host.env = &header->env;
2877 if (perf_data_file__is_pipe(file)) 2877 if (perf_data__is_pipe(data))
2878 return perf_header__read_pipe(session); 2878 return perf_header__read_pipe(session);
2879 2879
2880 if (perf_file_header__read(&f_header, header, fd) < 0) 2880 if (perf_file_header__read(&f_header, header, fd) < 0)
@@ -2889,7 +2889,7 @@ int perf_session__read_header(struct perf_session *session)
2889 if (f_header.data.size == 0) { 2889 if (f_header.data.size == 0) {
2890 pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n" 2890 pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n"
2891 "Was the 'perf record' command properly terminated?\n", 2891 "Was the 'perf record' command properly terminated?\n",
2892 file->path); 2892 data->path);
2893 } 2893 }
2894 2894
2895 nr_attrs = f_header.attrs.size / f_header.attr_size; 2895 nr_attrs = f_header.attrs.size / f_header.attr_size;
@@ -3397,7 +3397,7 @@ int perf_event__process_tracing_data(struct perf_tool *tool __maybe_unused,
3397 struct perf_session *session) 3397 struct perf_session *session)
3398{ 3398{
3399 ssize_t size_read, padding, size = event->tracing_data.size; 3399 ssize_t size_read, padding, size = event->tracing_data.size;
3400 int fd = perf_data_file__fd(session->file); 3400 int fd = perf_data__fd(session->data);
3401 off_t offset = lseek(fd, 0, SEEK_CUR); 3401 off_t offset = lseek(fd, 0, SEEK_CUR);
3402 char buf[BUFSIZ]; 3402 char buf[BUFSIZ];
3403 3403
diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c
index 218ee2bac9a5..5325e65f9711 100644
--- a/tools/perf/util/intel-bts.c
+++ b/tools/perf/util/intel-bts.c
@@ -500,7 +500,7 @@ static int intel_bts_process_queue(struct intel_bts_queue *btsq, u64 *timestamp)
500 } 500 }
501 501
502 if (!buffer->data) { 502 if (!buffer->data) {
503 int fd = perf_data_file__fd(btsq->bts->session->file); 503 int fd = perf_data__fd(btsq->bts->session->data);
504 504
505 buffer->data = auxtrace_buffer__get_data(buffer, fd); 505 buffer->data = auxtrace_buffer__get_data(buffer, fd);
506 if (!buffer->data) { 506 if (!buffer->data) {
@@ -664,10 +664,10 @@ static int intel_bts_process_auxtrace_event(struct perf_session *session,
664 if (!bts->data_queued) { 664 if (!bts->data_queued) {
665 struct auxtrace_buffer *buffer; 665 struct auxtrace_buffer *buffer;
666 off_t data_offset; 666 off_t data_offset;
667 int fd = perf_data_file__fd(session->file); 667 int fd = perf_data__fd(session->data);
668 int err; 668 int err;
669 669
670 if (perf_data_file__is_pipe(session->file)) { 670 if (perf_data__is_pipe(session->data)) {
671 data_offset = 0; 671 data_offset = 0;
672 } else { 672 } else {
673 data_offset = lseek(fd, 0, SEEK_CUR); 673 data_offset = lseek(fd, 0, SEEK_CUR);
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index b58f9fd1e2ee..23f9ba676df0 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -271,7 +271,7 @@ next:
271 ptq->buffer = buffer; 271 ptq->buffer = buffer;
272 272
273 if (!buffer->data) { 273 if (!buffer->data) {
274 int fd = perf_data_file__fd(ptq->pt->session->file); 274 int fd = perf_data__fd(ptq->pt->session->data);
275 275
276 buffer->data = auxtrace_buffer__get_data(buffer, fd); 276 buffer->data = auxtrace_buffer__get_data(buffer, fd);
277 if (!buffer->data) 277 if (!buffer->data)
@@ -2084,10 +2084,10 @@ static int intel_pt_process_auxtrace_event(struct perf_session *session,
2084 if (!pt->data_queued) { 2084 if (!pt->data_queued) {
2085 struct auxtrace_buffer *buffer; 2085 struct auxtrace_buffer *buffer;
2086 off_t data_offset; 2086 off_t data_offset;
2087 int fd = perf_data_file__fd(session->file); 2087 int fd = perf_data__fd(session->data);
2088 int err; 2088 int err;
2089 2089
2090 if (perf_data_file__is_pipe(session->file)) { 2090 if (perf_data__is_pipe(session->data)) {
2091 data_offset = 0; 2091 data_offset = 0;
2092 } else { 2092 } else {
2093 data_offset = lseek(fd, 0, SEEK_CUR); 2093 data_offset = lseek(fd, 0, SEEK_CUR);
diff --git a/tools/perf/util/jit.h b/tools/perf/util/jit.h
index 3f42ee4d2a0b..961e7a8a0e17 100644
--- a/tools/perf/util/jit.h
+++ b/tools/perf/util/jit.h
@@ -3,7 +3,7 @@
3 3
4#include <data.h> 4#include <data.h>
5 5
6int jit_process(struct perf_session *session, struct perf_data_file *output, 6int jit_process(struct perf_session *session, struct perf_data *output,
7 struct machine *machine, char *filename, pid_t pid, u64 *nbytes); 7 struct machine *machine, char *filename, pid_t pid, u64 *nbytes);
8 8
9int jit_inject_record(const char *filename); 9int jit_inject_record(const char *filename);
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index 9084930e1757..e7645098a323 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -29,7 +29,7 @@
29#include "sane_ctype.h" 29#include "sane_ctype.h"
30 30
31struct jit_buf_desc { 31struct jit_buf_desc {
32 struct perf_data_file *output; 32 struct perf_data *output;
33 struct perf_session *session; 33 struct perf_session *session;
34 struct machine *machine; 34 struct machine *machine;
35 union jr_entry *entry; 35 union jr_entry *entry;
@@ -60,8 +60,8 @@ struct debug_line_info {
60 60
61struct jit_tool { 61struct jit_tool {
62 struct perf_tool tool; 62 struct perf_tool tool;
63 struct perf_data_file output; 63 struct perf_data output;
64 struct perf_data_file input; 64 struct perf_data input;
65 u64 bytes_written; 65 u64 bytes_written;
66}; 66};
67 67
@@ -356,7 +356,7 @@ jit_inject_event(struct jit_buf_desc *jd, union perf_event *event)
356{ 356{
357 ssize_t size; 357 ssize_t size;
358 358
359 size = perf_data_file__write(jd->output, event, event->header.size); 359 size = perf_data__write(jd->output, event, event->header.size);
360 if (size < 0) 360 if (size < 0)
361 return -1; 361 return -1;
362 362
@@ -751,7 +751,7 @@ jit_detect(char *mmap_name, pid_t pid)
751 751
752int 752int
753jit_process(struct perf_session *session, 753jit_process(struct perf_session *session,
754 struct perf_data_file *output, 754 struct perf_data *output,
755 struct machine *machine, 755 struct machine *machine,
756 char *filename, 756 char *filename,
757 pid_t pid, 757 pid_t pid,
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b3fd62f7e4c9..c09b748ab599 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -32,14 +32,14 @@ static int perf_session__deliver_event(struct perf_session *session,
32 32
33static int perf_session__open(struct perf_session *session) 33static int perf_session__open(struct perf_session *session)
34{ 34{
35 struct perf_data_file *file = session->file; 35 struct perf_data *data = session->data;
36 36
37 if (perf_session__read_header(session) < 0) { 37 if (perf_session__read_header(session) < 0) {
38 pr_err("incompatible file format (rerun with -v to learn more)\n"); 38 pr_err("incompatible file format (rerun with -v to learn more)\n");
39 return -1; 39 return -1;
40 } 40 }
41 41
42 if (perf_data_file__is_pipe(file)) 42 if (perf_data__is_pipe(data))
43 return 0; 43 return 0;
44 44
45 if (perf_header__has_feat(&session->header, HEADER_STAT)) 45 if (perf_header__has_feat(&session->header, HEADER_STAT))
@@ -120,7 +120,7 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
120 session->tool, event->file_offset); 120 session->tool, event->file_offset);
121} 121}
122 122
123struct perf_session *perf_session__new(struct perf_data_file *file, 123struct perf_session *perf_session__new(struct perf_data *data,
124 bool repipe, struct perf_tool *tool) 124 bool repipe, struct perf_tool *tool)
125{ 125{
126 struct perf_session *session = zalloc(sizeof(*session)); 126 struct perf_session *session = zalloc(sizeof(*session));
@@ -134,13 +134,13 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
134 machines__init(&session->machines); 134 machines__init(&session->machines);
135 ordered_events__init(&session->ordered_events, ordered_events__deliver_event); 135 ordered_events__init(&session->ordered_events, ordered_events__deliver_event);
136 136
137 if (file) { 137 if (data) {
138 if (perf_data_file__open(file)) 138 if (perf_data__open(data))
139 goto out_delete; 139 goto out_delete;
140 140
141 session->file = file; 141 session->data = data;
142 142
143 if (perf_data_file__is_read(file)) { 143 if (perf_data__is_read(data)) {
144 if (perf_session__open(session) < 0) 144 if (perf_session__open(session) < 0)
145 goto out_close; 145 goto out_close;
146 146
@@ -148,7 +148,7 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
148 * set session attributes that are present in perf.data 148 * set session attributes that are present in perf.data
149 * but not in pipe-mode. 149 * but not in pipe-mode.
150 */ 150 */
151 if (!file->is_pipe) { 151 if (!data->is_pipe) {
152 perf_session__set_id_hdr_size(session); 152 perf_session__set_id_hdr_size(session);
153 perf_session__set_comm_exec(session); 153 perf_session__set_comm_exec(session);
154 } 154 }
@@ -157,7 +157,7 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
157 session->machines.host.env = &perf_env; 157 session->machines.host.env = &perf_env;
158 } 158 }
159 159
160 if (!file || perf_data_file__is_write(file)) { 160 if (!data || perf_data__is_write(data)) {
161 /* 161 /*
162 * In O_RDONLY mode this will be performed when reading the 162 * In O_RDONLY mode this will be performed when reading the
163 * kernel MMAP event, in perf_event__process_mmap(). 163 * kernel MMAP event, in perf_event__process_mmap().
@@ -170,7 +170,7 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
170 * In pipe-mode, evlist is empty until PERF_RECORD_HEADER_ATTR is 170 * In pipe-mode, evlist is empty until PERF_RECORD_HEADER_ATTR is
171 * processed, so perf_evlist__sample_id_all is not meaningful here. 171 * processed, so perf_evlist__sample_id_all is not meaningful here.
172 */ 172 */
173 if ((!file || !file->is_pipe) && tool && tool->ordering_requires_timestamps && 173 if ((!data || !data->is_pipe) && tool && tool->ordering_requires_timestamps &&
174 tool->ordered_events && !perf_evlist__sample_id_all(session->evlist)) { 174 tool->ordered_events && !perf_evlist__sample_id_all(session->evlist)) {
175 dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n"); 175 dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
176 tool->ordered_events = false; 176 tool->ordered_events = false;
@@ -179,7 +179,7 @@ struct perf_session *perf_session__new(struct perf_data_file *file,
179 return session; 179 return session;
180 180
181 out_close: 181 out_close:
182 perf_data_file__close(file); 182 perf_data__close(data);
183 out_delete: 183 out_delete:
184 perf_session__delete(session); 184 perf_session__delete(session);
185 out: 185 out:
@@ -201,8 +201,8 @@ void perf_session__delete(struct perf_session *session)
201 perf_session__delete_threads(session); 201 perf_session__delete_threads(session);
202 perf_env__exit(&session->header.env); 202 perf_env__exit(&session->header.env);
203 machines__exit(&session->machines); 203 machines__exit(&session->machines);
204 if (session->file) 204 if (session->data)
205 perf_data_file__close(session->file); 205 perf_data__close(session->data);
206 free(session); 206 free(session);
207} 207}
208 208
@@ -290,8 +290,8 @@ static s64 process_event_auxtrace_stub(struct perf_tool *tool __maybe_unused,
290 __maybe_unused) 290 __maybe_unused)
291{ 291{
292 dump_printf(": unhandled!\n"); 292 dump_printf(": unhandled!\n");
293 if (perf_data_file__is_pipe(session->file)) 293 if (perf_data__is_pipe(session->data))
294 skipn(perf_data_file__fd(session->file), event->auxtrace.size); 294 skipn(perf_data__fd(session->data), event->auxtrace.size);
295 return event->auxtrace.size; 295 return event->auxtrace.size;
296} 296}
297 297
@@ -1349,7 +1349,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
1349{ 1349{
1350 struct ordered_events *oe = &session->ordered_events; 1350 struct ordered_events *oe = &session->ordered_events;
1351 struct perf_tool *tool = session->tool; 1351 struct perf_tool *tool = session->tool;
1352 int fd = perf_data_file__fd(session->file); 1352 int fd = perf_data__fd(session->data);
1353 int err; 1353 int err;
1354 1354
1355 dump_event(session->evlist, event, file_offset, NULL); 1355 dump_event(session->evlist, event, file_offset, NULL);
@@ -1449,10 +1449,10 @@ int perf_session__peek_event(struct perf_session *session, off_t file_offset,
1449 goto out_parse_sample; 1449 goto out_parse_sample;
1450 } 1450 }
1451 1451
1452 if (perf_data_file__is_pipe(session->file)) 1452 if (perf_data__is_pipe(session->data))
1453 return -1; 1453 return -1;
1454 1454
1455 fd = perf_data_file__fd(session->file); 1455 fd = perf_data__fd(session->data);
1456 hdr_sz = sizeof(struct perf_event_header); 1456 hdr_sz = sizeof(struct perf_event_header);
1457 1457
1458 if (buf_sz < hdr_sz) 1458 if (buf_sz < hdr_sz)
@@ -1687,7 +1687,7 @@ static int __perf_session__process_pipe_events(struct perf_session *session)
1687{ 1687{
1688 struct ordered_events *oe = &session->ordered_events; 1688 struct ordered_events *oe = &session->ordered_events;
1689 struct perf_tool *tool = session->tool; 1689 struct perf_tool *tool = session->tool;
1690 int fd = perf_data_file__fd(session->file); 1690 int fd = perf_data__fd(session->data);
1691 union perf_event *event; 1691 union perf_event *event;
1692 uint32_t size, cur_size = 0; 1692 uint32_t size, cur_size = 0;
1693 void *buf = NULL; 1693 void *buf = NULL;
@@ -1828,7 +1828,7 @@ static int __perf_session__process_events(struct perf_session *session,
1828{ 1828{
1829 struct ordered_events *oe = &session->ordered_events; 1829 struct ordered_events *oe = &session->ordered_events;
1830 struct perf_tool *tool = session->tool; 1830 struct perf_tool *tool = session->tool;
1831 int fd = perf_data_file__fd(session->file); 1831 int fd = perf_data__fd(session->data);
1832 u64 head, page_offset, file_offset, file_pos, size; 1832 u64 head, page_offset, file_offset, file_pos, size;
1833 int err, mmap_prot, mmap_flags, map_idx = 0; 1833 int err, mmap_prot, mmap_flags, map_idx = 0;
1834 size_t mmap_size; 1834 size_t mmap_size;
@@ -1945,13 +1945,13 @@ out_err:
1945 1945
1946int perf_session__process_events(struct perf_session *session) 1946int perf_session__process_events(struct perf_session *session)
1947{ 1947{
1948 u64 size = perf_data_file__size(session->file); 1948 u64 size = perf_data__size(session->data);
1949 int err; 1949 int err;
1950 1950
1951 if (perf_session__register_idle_thread(session) < 0) 1951 if (perf_session__register_idle_thread(session) < 0)
1952 return -ENOMEM; 1952 return -ENOMEM;
1953 1953
1954 if (!perf_data_file__is_pipe(session->file)) 1954 if (!perf_data__is_pipe(session->data))
1955 err = __perf_session__process_events(session, 1955 err = __perf_session__process_events(session,
1956 session->header.data_offset, 1956 session->header.data_offset,
1957 session->header.data_size, size); 1957 session->header.data_size, size);
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 47b5e7dbcb18..cc1c5ea53c39 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -32,13 +32,13 @@ struct perf_session {
32 void *one_mmap_addr; 32 void *one_mmap_addr;
33 u64 one_mmap_offset; 33 u64 one_mmap_offset;
34 struct ordered_events ordered_events; 34 struct ordered_events ordered_events;
35 struct perf_data_file *file; 35 struct perf_data *data;
36 struct perf_tool *tool; 36 struct perf_tool *tool;
37}; 37};
38 38
39struct perf_tool; 39struct perf_tool;
40 40
41struct perf_session *perf_session__new(struct perf_data_file *file, 41struct perf_session *perf_session__new(struct perf_data *data,
42 bool repipe, struct perf_tool *tool); 42 bool repipe, struct perf_tool *tool);
43void perf_session__delete(struct perf_session *session); 43void perf_session__delete(struct perf_session *session);
44 44