Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Rename struct perf_data_file to perf_data

Rename struct perf_data_file to perf_data, because we will add the
possibility to have multiple files under perf.data, so the 'perf_data'
name fits better.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Changbin Du <changbin.du@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-39wn4d77phel3dgkzo3lyan0@git.kernel.org
[ Fixup recent changes in 'perf script --per-event-dump' ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
8ceb41d7 642ee1c6

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