diff options
author | Jiri Olsa <jolsa@redhat.com> | 2013-10-15 10:27:34 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-10-21 16:33:25 -0400 |
commit | cc9784bd9fa9d8e27fdea61142398cb85ce401a8 (patch) | |
tree | 920d1a84d2f4a4aef2b1b858546d723891158d23 /tools/perf | |
parent | 6a4d98d787b38a130a67e78b64182b419899623a (diff) |
perf session: Separating data file properties from session
Removing 'fd, fd_pipe, filename, size' from struct perf_session and
replacing them with struct perf_data_file object.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1381847254-28809-4-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-annotate.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 1 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 8 | ||||
-rw-r--r-- | tools/perf/builtin-script.c | 2 | ||||
-rw-r--r-- | tools/perf/util/data.h | 15 | ||||
-rw-r--r-- | tools/perf/util/header.c | 22 | ||||
-rw-r--r-- | tools/perf/util/session.c | 36 | ||||
-rw-r--r-- | tools/perf/util/session.h | 5 |
9 files changed, 56 insertions, 37 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 95df683d6074..03cfa592071f 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -259,7 +259,7 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | if (total_nr_samples == 0) { | 261 | if (total_nr_samples == 0) { |
262 | ui__error("The %s file has no samples!\n", session->filename); | 262 | ui__error("The %s file has no samples!\n", file.path); |
263 | goto out_delete; | 263 | goto out_delete; |
264 | } | 264 | } |
265 | 265 | ||
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 0164c1c3e834..ed3873b3e238 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -73,7 +73,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits) | |||
73 | * in pipe-mode, the only way to get the buildids is to parse | 73 | * in pipe-mode, the only way to get the buildids is to parse |
74 | * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID | 74 | * the record stream. Buildids are stored as RECORD_HEADER_BUILD_ID |
75 | */ | 75 | */ |
76 | if (with_hits || session->fd_pipe) | 76 | if (with_hits || perf_data_file__is_pipe(&file)) |
77 | perf_session__process_events(session, &build_id__mark_dso_hit_ops); | 77 | perf_session__process_events(session, &build_id__mark_dso_hit_ops); |
78 | 78 | ||
79 | perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits); | 79 | perf_session__fprintf_dsos_buildid(session, stdout, dso__skip_buildid, with_hits); |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 428e28f3e677..ab8d15e6e8cc 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -257,7 +257,6 @@ static int process_buildids(struct perf_record *rec) | |||
257 | if (size == 0) | 257 | if (size == 0) |
258 | return 0; | 258 | return 0; |
259 | 259 | ||
260 | session->fd = file->fd; | ||
261 | return __perf_session__process_events(session, rec->post_processing_offset, | 260 | return __perf_session__process_events(session, rec->post_processing_offset, |
262 | size - rec->post_processing_offset, | 261 | size - rec->post_processing_offset, |
263 | size, &build_id__mark_dso_hit_ops); | 262 | size, &build_id__mark_dso_hit_ops); |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 60d7f8ec8505..fa68a36bc461 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -368,8 +368,9 @@ static int perf_report__setup_sample_type(struct perf_report *rep) | |||
368 | { | 368 | { |
369 | struct perf_session *self = rep->session; | 369 | struct perf_session *self = rep->session; |
370 | u64 sample_type = perf_evlist__combined_sample_type(self->evlist); | 370 | u64 sample_type = perf_evlist__combined_sample_type(self->evlist); |
371 | bool is_pipe = perf_data_file__is_pipe(self->file); | ||
371 | 372 | ||
372 | if (!self->fd_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) { | 373 | if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) { |
373 | if (sort__has_parent) { | 374 | if (sort__has_parent) { |
374 | ui__error("Selected --sort parent, but no " | 375 | ui__error("Selected --sort parent, but no " |
375 | "callchain data. Did you call " | 376 | "callchain data. Did you call " |
@@ -392,7 +393,7 @@ static int perf_report__setup_sample_type(struct perf_report *rep) | |||
392 | } | 393 | } |
393 | 394 | ||
394 | if (sort__mode == SORT_MODE__BRANCH) { | 395 | if (sort__mode == SORT_MODE__BRANCH) { |
395 | if (!self->fd_pipe && | 396 | if (!is_pipe && |
396 | !(sample_type & PERF_SAMPLE_BRANCH_STACK)) { | 397 | !(sample_type & PERF_SAMPLE_BRANCH_STACK)) { |
397 | ui__error("Selected -b but no branch data. " | 398 | ui__error("Selected -b but no branch data. " |
398 | "Did you call perf record without -b?\n"); | 399 | "Did you call perf record without -b?\n"); |
@@ -488,6 +489,7 @@ static int __cmd_report(struct perf_report *rep) | |||
488 | struct map *kernel_map; | 489 | struct map *kernel_map; |
489 | struct kmap *kernel_kmap; | 490 | struct kmap *kernel_kmap; |
490 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; | 491 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; |
492 | struct perf_data_file *file = session->file; | ||
491 | 493 | ||
492 | signal(SIGINT, sig_handler); | 494 | signal(SIGINT, sig_handler); |
493 | 495 | ||
@@ -572,7 +574,7 @@ static int __cmd_report(struct perf_report *rep) | |||
572 | return 0; | 574 | return 0; |
573 | 575 | ||
574 | if (nr_samples == 0) { | 576 | if (nr_samples == 0) { |
575 | ui__error("The %s file has no samples!\n", session->filename); | 577 | ui__error("The %s file has no samples!\n", file->path); |
576 | return 0; | 578 | return 0; |
577 | } | 579 | } |
578 | 580 | ||
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index f0c77a199616..27de6068049d 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -1525,7 +1525,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1525 | return -1; | 1525 | return -1; |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | input = open(session->filename, O_RDONLY); /* input_name */ | 1528 | input = open(file.path, O_RDONLY); /* input_name */ |
1529 | if (input < 0) { | 1529 | if (input < 0) { |
1530 | perror("failed to open file"); | 1530 | perror("failed to open file"); |
1531 | return -1; | 1531 | return -1; |
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h index d6c262e42f47..8c2df80152a5 100644 --- a/tools/perf/util/data.h +++ b/tools/perf/util/data.h | |||
@@ -27,6 +27,21 @@ static inline bool perf_data_file__is_write(struct perf_data_file *file) | |||
27 | return file->mode == PERF_DATA_MODE_WRITE; | 27 | return file->mode == PERF_DATA_MODE_WRITE; |
28 | } | 28 | } |
29 | 29 | ||
30 | static inline int perf_data_file__is_pipe(struct perf_data_file *file) | ||
31 | { | ||
32 | return file->is_pipe; | ||
33 | } | ||
34 | |||
35 | static inline int perf_data_file__fd(struct perf_data_file *file) | ||
36 | { | ||
37 | return file->fd; | ||
38 | } | ||
39 | |||
40 | static inline unsigned long perf_data_file__size(struct perf_data_file *file) | ||
41 | { | ||
42 | return file->size; | ||
43 | } | ||
44 | |||
30 | int perf_data_file__open(struct perf_data_file *file); | 45 | int perf_data_file__open(struct perf_data_file *file); |
31 | void perf_data_file__close(struct perf_data_file *file); | 46 | void perf_data_file__close(struct perf_data_file *file); |
32 | 47 | ||
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index c3e5a3b817ab..26d9520a0c1b 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "vdso.h" | 22 | #include "vdso.h" |
23 | #include "strbuf.h" | 23 | #include "strbuf.h" |
24 | #include "build-id.h" | 24 | #include "build-id.h" |
25 | #include "data.h" | ||
25 | 26 | ||
26 | static bool no_buildid_cache = false; | 27 | static bool no_buildid_cache = false; |
27 | 28 | ||
@@ -2189,7 +2190,7 @@ int perf_header__fprintf_info(struct perf_session *session, FILE *fp, bool full) | |||
2189 | { | 2190 | { |
2190 | struct header_print_data hd; | 2191 | struct header_print_data hd; |
2191 | struct perf_header *header = &session->header; | 2192 | struct perf_header *header = &session->header; |
2192 | int fd = session->fd; | 2193 | int fd = perf_data_file__fd(session->file); |
2193 | hd.fp = fp; | 2194 | hd.fp = fp; |
2194 | hd.full = full; | 2195 | hd.full = full; |
2195 | 2196 | ||
@@ -2650,7 +2651,8 @@ static int perf_header__read_pipe(struct perf_session *session) | |||
2650 | struct perf_header *header = &session->header; | 2651 | struct perf_header *header = &session->header; |
2651 | struct perf_pipe_file_header f_header; | 2652 | struct perf_pipe_file_header f_header; |
2652 | 2653 | ||
2653 | if (perf_file_header__read_pipe(&f_header, header, session->fd, | 2654 | if (perf_file_header__read_pipe(&f_header, header, |
2655 | perf_data_file__fd(session->file), | ||
2654 | session->repipe) < 0) { | 2656 | session->repipe) < 0) { |
2655 | pr_debug("incompatible file format\n"); | 2657 | pr_debug("incompatible file format\n"); |
2656 | return -EINVAL; | 2658 | return -EINVAL; |
@@ -2751,18 +2753,19 @@ static int perf_evlist__prepare_tracepoint_events(struct perf_evlist *evlist, | |||
2751 | 2753 | ||
2752 | int perf_session__read_header(struct perf_session *session) | 2754 | int perf_session__read_header(struct perf_session *session) |
2753 | { | 2755 | { |
2756 | struct perf_data_file *file = session->file; | ||
2754 | struct perf_header *header = &session->header; | 2757 | struct perf_header *header = &session->header; |
2755 | struct perf_file_header f_header; | 2758 | struct perf_file_header f_header; |
2756 | struct perf_file_attr f_attr; | 2759 | struct perf_file_attr f_attr; |
2757 | u64 f_id; | 2760 | u64 f_id; |
2758 | int nr_attrs, nr_ids, i, j; | 2761 | int nr_attrs, nr_ids, i, j; |
2759 | int fd = session->fd; | 2762 | int fd = perf_data_file__fd(file); |
2760 | 2763 | ||
2761 | session->evlist = perf_evlist__new(); | 2764 | session->evlist = perf_evlist__new(); |
2762 | if (session->evlist == NULL) | 2765 | if (session->evlist == NULL) |
2763 | return -ENOMEM; | 2766 | return -ENOMEM; |
2764 | 2767 | ||
2765 | if (session->fd_pipe) | 2768 | if (perf_data_file__is_pipe(file)) |
2766 | return perf_header__read_pipe(session); | 2769 | return perf_header__read_pipe(session); |
2767 | 2770 | ||
2768 | if (perf_file_header__read(&f_header, header, fd) < 0) | 2771 | if (perf_file_header__read(&f_header, header, fd) < 0) |
@@ -2777,7 +2780,7 @@ int perf_session__read_header(struct perf_session *session) | |||
2777 | if (f_header.data.size == 0) { | 2780 | if (f_header.data.size == 0) { |
2778 | pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n" | 2781 | pr_warning("WARNING: The %s file's data size field is 0 which is unexpected.\n" |
2779 | "Was the 'perf record' command properly terminated?\n", | 2782 | "Was the 'perf record' command properly terminated?\n", |
2780 | session->filename); | 2783 | file->path); |
2781 | } | 2784 | } |
2782 | 2785 | ||
2783 | nr_attrs = f_header.attrs.size / f_header.attr_size; | 2786 | nr_attrs = f_header.attrs.size / f_header.attr_size; |
@@ -2990,18 +2993,19 @@ int perf_event__process_tracing_data(struct perf_tool *tool __maybe_unused, | |||
2990 | struct perf_session *session) | 2993 | struct perf_session *session) |
2991 | { | 2994 | { |
2992 | ssize_t size_read, padding, size = event->tracing_data.size; | 2995 | ssize_t size_read, padding, size = event->tracing_data.size; |
2993 | off_t offset = lseek(session->fd, 0, SEEK_CUR); | 2996 | int fd = perf_data_file__fd(session->file); |
2997 | off_t offset = lseek(fd, 0, SEEK_CUR); | ||
2994 | char buf[BUFSIZ]; | 2998 | char buf[BUFSIZ]; |
2995 | 2999 | ||
2996 | /* setup for reading amidst mmap */ | 3000 | /* setup for reading amidst mmap */ |
2997 | lseek(session->fd, offset + sizeof(struct tracing_data_event), | 3001 | lseek(fd, offset + sizeof(struct tracing_data_event), |
2998 | SEEK_SET); | 3002 | SEEK_SET); |
2999 | 3003 | ||
3000 | size_read = trace_report(session->fd, &session->pevent, | 3004 | size_read = trace_report(fd, &session->pevent, |
3001 | session->repipe); | 3005 | session->repipe); |
3002 | padding = PERF_ALIGN(size_read, sizeof(u64)) - size_read; | 3006 | padding = PERF_ALIGN(size_read, sizeof(u64)) - size_read; |
3003 | 3007 | ||
3004 | if (readn(session->fd, buf, padding) < 0) { | 3008 | if (readn(fd, buf, padding) < 0) { |
3005 | pr_err("%s: reading input file", __func__); | 3009 | pr_err("%s: reading input file", __func__); |
3006 | return -1; | 3010 | return -1; |
3007 | } | 3011 | } |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index d857c18d2eeb..19fc71678c8e 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -18,17 +18,16 @@ | |||
18 | 18 | ||
19 | static int perf_session__open(struct perf_session *self) | 19 | static int perf_session__open(struct perf_session *self) |
20 | { | 20 | { |
21 | if (self->fd_pipe) { | 21 | struct perf_data_file *file = self->file; |
22 | if (perf_session__read_header(self) < 0) | ||
23 | pr_err("incompatible file format (rerun with -v to learn more)"); | ||
24 | return 0; | ||
25 | } | ||
26 | 22 | ||
27 | if (perf_session__read_header(self) < 0) { | 23 | if (perf_session__read_header(self) < 0) { |
28 | pr_err("incompatible file format (rerun with -v to learn more)"); | 24 | pr_err("incompatible file format (rerun with -v to learn more)"); |
29 | return -1; | 25 | return -1; |
30 | } | 26 | } |
31 | 27 | ||
28 | if (perf_data_file__is_pipe(file)) | ||
29 | return 0; | ||
30 | |||
32 | if (!perf_evlist__valid_sample_type(self->evlist)) { | 31 | if (!perf_evlist__valid_sample_type(self->evlist)) { |
33 | pr_err("non matching sample_type"); | 32 | pr_err("non matching sample_type"); |
34 | return -1; | 33 | return -1; |
@@ -87,10 +86,7 @@ struct perf_session *perf_session__new(struct perf_data_file *file, | |||
87 | if (perf_data_file__open(file)) | 86 | if (perf_data_file__open(file)) |
88 | goto out_delete; | 87 | goto out_delete; |
89 | 88 | ||
90 | self->fd = file->fd; | 89 | self->file = file; |
91 | self->fd_pipe = file->is_pipe; | ||
92 | self->filename = file->path; | ||
93 | self->size = file->size; | ||
94 | 90 | ||
95 | if (perf_data_file__is_read(file)) { | 91 | if (perf_data_file__is_read(file)) { |
96 | if (perf_session__open(self) < 0) | 92 | if (perf_session__open(self) < 0) |
@@ -158,7 +154,8 @@ void perf_session__delete(struct perf_session *self) | |||
158 | perf_session__delete_threads(self); | 154 | perf_session__delete_threads(self); |
159 | perf_session_env__delete(&self->header.env); | 155 | perf_session_env__delete(&self->header.env); |
160 | machines__exit(&self->machines); | 156 | machines__exit(&self->machines); |
161 | close(self->fd); | 157 | if (self->file) |
158 | perf_data_file__close(self->file); | ||
162 | free(self); | 159 | free(self); |
163 | vdso__exit(); | 160 | vdso__exit(); |
164 | } | 161 | } |
@@ -1015,6 +1012,7 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
1015 | static int perf_session__process_user_event(struct perf_session *session, union perf_event *event, | 1012 | static int perf_session__process_user_event(struct perf_session *session, union perf_event *event, |
1016 | struct perf_tool *tool, u64 file_offset) | 1013 | struct perf_tool *tool, u64 file_offset) |
1017 | { | 1014 | { |
1015 | int fd = perf_data_file__fd(session->file); | ||
1018 | int err; | 1016 | int err; |
1019 | 1017 | ||
1020 | dump_event(session, event, file_offset, NULL); | 1018 | dump_event(session, event, file_offset, NULL); |
@@ -1028,7 +1026,7 @@ static int perf_session__process_user_event(struct perf_session *session, union | |||
1028 | return err; | 1026 | return err; |
1029 | case PERF_RECORD_HEADER_TRACING_DATA: | 1027 | case PERF_RECORD_HEADER_TRACING_DATA: |
1030 | /* setup for reading amidst mmap */ | 1028 | /* setup for reading amidst mmap */ |
1031 | lseek(session->fd, file_offset, SEEK_SET); | 1029 | lseek(fd, file_offset, SEEK_SET); |
1032 | return tool->tracing_data(tool, event, session); | 1030 | return tool->tracing_data(tool, event, session); |
1033 | case PERF_RECORD_HEADER_BUILD_ID: | 1031 | case PERF_RECORD_HEADER_BUILD_ID: |
1034 | return tool->build_id(tool, event, session); | 1032 | return tool->build_id(tool, event, session); |
@@ -1154,6 +1152,7 @@ volatile int session_done; | |||
1154 | static int __perf_session__process_pipe_events(struct perf_session *self, | 1152 | static int __perf_session__process_pipe_events(struct perf_session *self, |
1155 | struct perf_tool *tool) | 1153 | struct perf_tool *tool) |
1156 | { | 1154 | { |
1155 | int fd = perf_data_file__fd(self->file); | ||
1157 | union perf_event *event; | 1156 | union perf_event *event; |
1158 | uint32_t size, cur_size = 0; | 1157 | uint32_t size, cur_size = 0; |
1159 | void *buf = NULL; | 1158 | void *buf = NULL; |
@@ -1172,7 +1171,7 @@ static int __perf_session__process_pipe_events(struct perf_session *self, | |||
1172 | return -errno; | 1171 | return -errno; |
1173 | more: | 1172 | more: |
1174 | event = buf; | 1173 | event = buf; |
1175 | err = readn(self->fd, event, sizeof(struct perf_event_header)); | 1174 | err = readn(fd, event, sizeof(struct perf_event_header)); |
1176 | if (err <= 0) { | 1175 | if (err <= 0) { |
1177 | if (err == 0) | 1176 | if (err == 0) |
1178 | goto done; | 1177 | goto done; |
@@ -1204,7 +1203,7 @@ more: | |||
1204 | p += sizeof(struct perf_event_header); | 1203 | p += sizeof(struct perf_event_header); |
1205 | 1204 | ||
1206 | if (size - sizeof(struct perf_event_header)) { | 1205 | if (size - sizeof(struct perf_event_header)) { |
1207 | err = readn(self->fd, p, size - sizeof(struct perf_event_header)); | 1206 | err = readn(fd, p, size - sizeof(struct perf_event_header)); |
1208 | if (err <= 0) { | 1207 | if (err <= 0) { |
1209 | if (err == 0) { | 1208 | if (err == 0) { |
1210 | pr_err("unexpected end of event stream\n"); | 1209 | pr_err("unexpected end of event stream\n"); |
@@ -1285,6 +1284,7 @@ int __perf_session__process_events(struct perf_session *session, | |||
1285 | u64 data_offset, u64 data_size, | 1284 | u64 data_offset, u64 data_size, |
1286 | u64 file_size, struct perf_tool *tool) | 1285 | u64 file_size, struct perf_tool *tool) |
1287 | { | 1286 | { |
1287 | int fd = perf_data_file__fd(session->file); | ||
1288 | u64 head, page_offset, file_offset, file_pos, progress_next; | 1288 | u64 head, page_offset, file_offset, file_pos, progress_next; |
1289 | int err, mmap_prot, mmap_flags, map_idx = 0; | 1289 | int err, mmap_prot, mmap_flags, map_idx = 0; |
1290 | size_t mmap_size; | 1290 | size_t mmap_size; |
@@ -1317,7 +1317,7 @@ int __perf_session__process_events(struct perf_session *session, | |||
1317 | mmap_flags = MAP_PRIVATE; | 1317 | mmap_flags = MAP_PRIVATE; |
1318 | } | 1318 | } |
1319 | remap: | 1319 | remap: |
1320 | buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, session->fd, | 1320 | buf = mmap(NULL, mmap_size, mmap_prot, mmap_flags, fd, |
1321 | file_offset); | 1321 | file_offset); |
1322 | if (buf == MAP_FAILED) { | 1322 | if (buf == MAP_FAILED) { |
1323 | pr_err("failed to mmap file\n"); | 1323 | pr_err("failed to mmap file\n"); |
@@ -1382,16 +1382,17 @@ out_err: | |||
1382 | int perf_session__process_events(struct perf_session *self, | 1382 | int perf_session__process_events(struct perf_session *self, |
1383 | struct perf_tool *tool) | 1383 | struct perf_tool *tool) |
1384 | { | 1384 | { |
1385 | u64 size = perf_data_file__size(self->file); | ||
1385 | int err; | 1386 | int err; |
1386 | 1387 | ||
1387 | if (perf_session__register_idle_thread(self) == NULL) | 1388 | if (perf_session__register_idle_thread(self) == NULL) |
1388 | return -ENOMEM; | 1389 | return -ENOMEM; |
1389 | 1390 | ||
1390 | if (!self->fd_pipe) | 1391 | if (!perf_data_file__is_pipe(self->file)) |
1391 | err = __perf_session__process_events(self, | 1392 | err = __perf_session__process_events(self, |
1392 | self->header.data_offset, | 1393 | self->header.data_offset, |
1393 | self->header.data_size, | 1394 | self->header.data_size, |
1394 | self->size, tool); | 1395 | size, tool); |
1395 | else | 1396 | else |
1396 | err = __perf_session__process_pipe_events(self, tool); | 1397 | err = __perf_session__process_pipe_events(self, tool); |
1397 | 1398 | ||
@@ -1615,13 +1616,14 @@ int perf_session__cpu_bitmap(struct perf_session *session, | |||
1615 | void perf_session__fprintf_info(struct perf_session *session, FILE *fp, | 1616 | void perf_session__fprintf_info(struct perf_session *session, FILE *fp, |
1616 | bool full) | 1617 | bool full) |
1617 | { | 1618 | { |
1619 | int fd = perf_data_file__fd(session->file); | ||
1618 | struct stat st; | 1620 | struct stat st; |
1619 | int ret; | 1621 | int ret; |
1620 | 1622 | ||
1621 | if (session == NULL || fp == NULL) | 1623 | if (session == NULL || fp == NULL) |
1622 | return; | 1624 | return; |
1623 | 1625 | ||
1624 | ret = fstat(session->fd, &st); | 1626 | ret = fstat(fd, &st); |
1625 | if (ret == -1) | 1627 | if (ret == -1) |
1626 | return; | 1628 | return; |
1627 | 1629 | ||
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index e1ca2d0ae541..27c74d38b868 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -30,16 +30,13 @@ struct ordered_samples { | |||
30 | 30 | ||
31 | struct perf_session { | 31 | struct perf_session { |
32 | struct perf_header header; | 32 | struct perf_header header; |
33 | unsigned long size; | ||
34 | struct machines machines; | 33 | struct machines machines; |
35 | struct perf_evlist *evlist; | 34 | struct perf_evlist *evlist; |
36 | struct pevent *pevent; | 35 | struct pevent *pevent; |
37 | struct events_stats stats; | 36 | struct events_stats stats; |
38 | int fd; | ||
39 | bool fd_pipe; | ||
40 | bool repipe; | 37 | bool repipe; |
41 | struct ordered_samples ordered_samples; | 38 | struct ordered_samples ordered_samples; |
42 | const char *filename; | 39 | struct perf_data_file *file; |
43 | }; | 40 | }; |
44 | 41 | ||
45 | #define PRINT_IP_OPT_IP (1<<0) | 42 | #define PRINT_IP_OPT_IP (1<<0) |