Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1236388
| From | Jiri Olsa <jolsa@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 23/45] perf stat record: Add pipe support for record command |
| Date | 2015-09-30 16:30 +0200 |
| Message-ID | <qeqym-7BV-19@gated-at.bofh.it> (permalink) |
| References | <qeqoF-7qA-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 7bd5bde5fa7c..74aac55ff24a 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;
@@ -1538,8 +1553,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
[PATCHv2 00/45] perf stat: Add scripting support Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 44/45] perf script: Add python support for stat events Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 40/45] perf script: Process stat config event Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 05/45] perf tools: Add cpu_map event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 29/45] perf tools: Add data arg to cpu_map__build_map callback Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 34/45] perf stat report: Add support to initialize aggr_map from file Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 30/45] perf stat report: Cache aggregated map entries in extra cpumap Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:20 +0200
[PATCH 09/45] perf tools: Add stat config event read function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 18/45] perf stat: Add AGGR_UNSET mode Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 11/45] perf tools: Add stat event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 17/45] perf stat: Rename perf_stat struct into perf_stat_evsel Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 23/45] perf stat record: Add pipe support for record command Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 12/45] perf tools: Add stat event read function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 02/45] perf tools: Add thread_map event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 14/45] perf tools: Add stat round event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 15/45] perf tools: Introduce stat feature Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 04/45] perf tools: Add cpu_map event Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 22/45] perf stat record: Store events IDs in perf data file Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 08/45] perf tools: Add stat config event synthesize function Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 19/45] perf stat record: Add record command Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
[PATCH 21/45] perf stat record: Synthesize stat record data Jiri Olsa <jolsa@kernel.org> - 2015-09-30 16:30 +0200
RE: [PATCHv2 00/45] perf stat: Add scripting support "Liang, Kan" <kan.liang@intel.com> - 2015-09-30 23:20 +0200
Re: [PATCHv2 00/45] perf stat: Add scripting support Jiri Olsa <jolsa@redhat.com> - 2015-09-30 23:40 +0200
Re: [PATCHv2 00/45] perf stat: Add scripting support Jiri Olsa <jolsa@redhat.com> - 2015-09-30 23:40 +0200
csiph-web