Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1248643
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 34/57] perf stat record: Add pipe support for record command |
| Date | 2015-10-16 13:00 +0200 |
| Message-ID | <qkaTV-3YR-45@gated-at.bofh.it> (permalink) |
| References | <qkaKe-3Nh-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Allowing storing stat record data into pipe, so report
tools (report/script) could read data directly from
record.
Link: http://lkml.kernel.org/n/tip-m8fj758gty57hgvss5efy6na@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/builtin-stat.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 39a6ecd532b6..539566eeea97 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -291,10 +291,19 @@ static void workload_exec_failed_signal(int signo __maybe_unused, siginfo_t *inf
workload_exec_errno = info->si_value.sival_int;
}
-static int perf_stat_synthesize_config(void)
+static int perf_stat_synthesize_config(bool is_pipe)
{
int err;
+ if (is_pipe) {
+ err = perf_event__synthesize_attrs(NULL, perf_stat.session,
+ process_synthesized_event);
+ if (err < 0) {
+ pr_err("Couldn't synthesize attrs.\n");
+ return err;
+ }
+ }
+
err = perf_event__synthesize_thread_map2(NULL, evsel_list->threads,
process_synthesized_event,
NULL);
@@ -362,6 +371,7 @@ static int __run_perf_stat(int argc, const char **argv)
size_t l;
int status = 0;
const bool forks = (argc > 0);
+ bool is_pipe = STAT_RECORD ? perf_stat.file.is_pipe : false;
if (interval) {
ts.tv_sec = interval / 1000;
@@ -372,7 +382,7 @@ static int __run_perf_stat(int argc, const char **argv)
}
if (forks) {
- if (perf_evlist__prepare_workload(evsel_list, &target, argv, false,
+ if (perf_evlist__prepare_workload(evsel_list, &target, argv, is_pipe,
workload_exec_failed_signal) < 0) {
perror("failed to prepare workload");
return -1;
@@ -431,12 +441,17 @@ static int __run_perf_stat(int argc, const char **argv)
if (STAT_RECORD) {
int err, fd = perf_data_file__fd(&perf_stat.file);
- err = perf_session__write_header(perf_stat.session, evsel_list,
- fd, false);
+ if (is_pipe) {
+ err = perf_header__write_pipe(perf_data_file__fd(&perf_stat.file));
+ } else {
+ err = perf_session__write_header(perf_stat.session, evsel_list,
+ fd, false);
+ }
+
if (err < 0)
return err;
- err = perf_stat_synthesize_config();
+ err = perf_stat_synthesize_config(is_pipe);
if (err < 0)
return err;
}
@@ -963,6 +978,10 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
struct perf_evsel *counter;
char buf[64], *prefix = NULL;
+ /* Do not print anything if we record to the pipe. */
+ if (STAT_RECORD && perf_stat.file.is_pipe)
+ return;
+
if (interval)
print_interval(prefix = buf, ts);
else
@@ -1268,10 +1287,6 @@ static int __cmd_record(int argc, const char **argv)
return -1;
}
- /* No pipe support ATM */
- if (perf_stat.file.is_pipe)
- return -EINVAL;
-
init_features(session);
session->evlist = evsel_list;
@@ -1543,8 +1558,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __maybe_unused)
if (STAT_RECORD) {
int fd = perf_data_file__fd(&perf_stat.file);
- perf_stat.session->header.data_size += perf_stat.bytes_written;
- perf_session__write_header(perf_stat.session, evsel_list, fd, true);
+ if (!perf_stat.file.is_pipe) {
+ perf_stat.session->header.data_size += perf_stat.bytes_written;
+ perf_session__write_header(perf_stat.session, evsel_list, fd, true);
+ }
perf_session__delete(perf_stat.session);
}
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv4 00/57] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 50/57] perf script: Check output fields only for samples Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 27/57] perf tools: Move id_offset out of struct perf_evsel union Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 41/57] perf stat report: Cache aggregated map entries in extra cpumap Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 35/57] perf stat record: Write stat events on record Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 06/57] perf tools: Add cpu_map event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 38/57] perf stat record: Synthesize attr update events Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 25/57] perf report: Display newly added events in raw dump Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 43/57] perf stat report: Process cpu/threads maps Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 08/57] perf tools: Add cpu_map__new_event function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 30/57] perf stat record: Add record command Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 39/57] perf tools: Make cpu_map__build_map global Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 49/57] perf stat report: Allow to override aggr_mode Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 03/57] perf tools: Add thread_map__new_event function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 40/57] perf tools: Add data arg to cpu_map__build_map callback Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 42/57] perf stat report: Add report command Jiri Olsa <jolsa@kernel.org> - 2015-10-16 12:50 +0200 [PATCH 15/57] perf tools: Add stat event read function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 11/57] perf tools: Add stat config event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 33/57] perf stat record: Store events IDs in perf data file Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 21/57] perf tools: Add attr_update event scale type Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 18/57] perf tools: Add stat events fprintf functions Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 09/57] perf tools: Add perf_event__fprintf_cpu_map function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 17/57] perf tools: Add stat round event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 07/57] perf tools: Add cpu_map__empty_new function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 26/57] perf tools: Introduce stat feature Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 36/57] perf stat record: Write stat round events on record Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 10/57] perf tools: Add stat config event Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 04/57] perf tools: Add perf_event__fprintf_thread_map function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 20/57] perf tools: Add attr_update event unit type Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 05/57] perf tools: Add cpu_map event Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 13/57] perf tools: Add stat event Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 24/57] perf tools: Add perf_event__fprintf_attr_update function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 29/57] perf stat: Add AGGR_UNSET mode Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 34/57] perf stat record: Add pipe support for record command Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 31/57] perf stat record: Initialize record features Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:00 +0200 [PATCH 02/57] perf tools: Add thread_map event sythesize function Jiri Olsa <jolsa@kernel.org> - 2015-10-16 13:10 +0200
csiph-web