From: David Carrillo-Cisneros <davidcc@google.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>, Simon Que <sque@chromium.org>,
Wang Nan <wangnan0@huawei.com>, Jiri Olsa <jolsa@kernel.org>,
He Kuang <hekuang@huawei.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Stephane Eranian <eranian@google.com>,
Paul Turner <pjt@google.com>,
David Carrillo-Cisneros <davidcc@google.com>
Subject: [PATCH v3 15/15] perf header: add event desc to pipe-mode header
Date: Tue, 6 Jun 2017 00:07:22 -0700 [thread overview]
Message-ID: <20170606070722.35213-16-davidcc@google.com> (raw)
In-Reply-To: <20170606070722.35213-1-davidcc@google.com>
Add event descriptor to perf header output in pipe-mode.
After this patch:
$ perf record -e cycles sleep 1 | perf report --header
# ========
# captured on: Mon Jun 5 22:52:13 2017
# ========
#
# hostname : lphh20
# os release : 4.3.5-smp-801.43.0.0
# perf version : 4.12.rc2.g439987
# arch : x86_64
# nrcpus online : 72
# nrcpus avail : 72
# cpudesc : Intel(R) Xeon(R) CPU E5-2696 v3 @ 2.30GHz
# cpuid : GenuineIntel,6,63,2
# total memory : 264134144 kB
# cmdline : /root/perf record -e cycles sleep 1
# event : name = cycles, , size = 112, { sample_period, sample_freq } = 4000, sample_type = IP|TID|TIME|PERIOD, disabled = 1, inherit = 1, mmap = 1, comm = 1, freq = 1, enable_on_exec = 1, task = 1, sample_id_all = 1, exclude_guest = 1, mmap2 = 1, comm_exec = 1
# CPU_TOPOLOGY info available, use -I to display
# NUMA_TOPOLOGY info available, use -I to display
# pmu mappings: intel_bts = 6, cpu = 4, msr = 49, uncore_cbox_10 = 36, uncore_cbox_11 = 37, uncore_cbox_12 = 38, uncore_cbox_13 = 39, uncore_cbox_14 = 40, uncore_cbox_15 = 41, uncore_cbox_16 = 42, uncore_cbox_17 = 43, software = 1, power = 7, uncore_irp = 24, uncore_pcu = 48, tracepoint = 2, uncore_imc_0 = 16, uncore_imc_1 = 17, uncore_imc_2 = 18, uncore_imc_3 = 19, uncore_imc_4 = 20, uncore_imc_5 = 21, uncore_imc_6 = 22, uncore_imc_7 = 23, uncore_qpi_0 = 8, uncore_qpi_1 = 9, uncore_cbox_0 = 26, uncore_cbox_1 = 27, uncore_cbox_2 = 28, uncore_cbox_3 = 29, uncore_cbox_4 = 30, uncore_cbox_5 = 31, uncore_cbox_6 = 32, uncore_cbox_7 = 33, uncore_cbox_8 = 34, uncore_cbox_9 = 35, uncore_r2pcie = 13, uncore_r3qpi_0 = 10, uncore_r3qpi_1 = 11, uncore_r3qpi_2 = 12, uncore_sbox_0 = 44, uncore_sbox_1 = 45, uncore_sbox_2 = 46, uncore_sbox_3 = 47, breakpoint = 5, uncore_ha_0 = 14, uncore_ha_1 = 15, uncore_ubox = 25
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB (null) ]
Prior to this patch, event was not printed.
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
---
| 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 6c1963e5bf10..c91acd5b0838 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -66,6 +66,7 @@ struct feat_fd {
void *buf; /* Either buf != NULL or fd >= 0 */
ssize_t offset;
size_t size;
+ struct perf_evsel *events;
};
void perf_header__set_feat(struct perf_header *header, int feat)
@@ -1353,10 +1354,15 @@ static int __desc_attr__fprintf(FILE *fp, const char *name, const char *val,
static void print_event_desc(struct feat_fd *ff, FILE *fp)
{
- struct perf_evsel *evsel, *events = read_event_desc(ff);
+ struct perf_evsel *evsel, *events;
u32 j;
u64 *id;
+ if (ff->events)
+ events = ff->events;
+ else
+ events = read_event_desc(ff);
+
if (!events) {
fprintf(fp, "# event desc: not available or unable to read\n");
return;
@@ -1381,6 +1387,7 @@ static void print_event_desc(struct feat_fd *ff, FILE *fp)
}
free_event_desc(events);
+ ff->events = NULL;
}
static void print_total_mem(struct feat_fd *ff, FILE *fp)
@@ -1743,10 +1750,18 @@ process_event_desc(struct feat_fd *ff, void *data __maybe_unused)
return 0;
session = container_of(ff->ph, struct perf_session, header);
+
+ if (session->file->is_pipe) {
+ /* Save events for reading later by print_event_desc,
+ * since they can't be read again in pipe mode. */
+ ff->events = events;
+ }
+
for (evsel = events; evsel->attr.size; evsel++)
perf_evlist__set_event_name(session->evlist, evsel);
- free_event_desc(events);
+ if (!session->file->is_pipe)
+ free_event_desc(events);
return 0;
}
--
2.13.1.508.gb3defc5cc-goog
next prev parent reply other threads:[~2017-06-06 7:08 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 7:07 [PATCH v3 00/15] perf tool: add meta-data header support for pipe-mode David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 01/15] perf header: encapsulate read and swap David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 02/15] perf header: add PROCESS_STR_FUN macro David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 03/15] perf header: fail on write_padded error David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 04/15] perf util: add const modifier to buf in "writen" function David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 05/15] perf header: revamp do_write David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 06/15] perf header: add struct feat_fd for write David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 07/15] perf header: use struct feat_fd for print David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 08/15] perf header: use struct feat_fd to process header records David Carrillo-Cisneros
2017-06-08 11:54 ` Jiri Olsa
2017-06-13 4:18 ` David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 09/15] perf header: use struct feat_fd in read " David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 10/15] perf header: make write_pmu_mappings pipe-mode friendly David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 11/15] perf header: add a buffer to struct feat_fd David Carrillo-Cisneros
2017-06-08 11:54 ` Jiri Olsa
2017-06-08 11:54 ` Jiri Olsa
2017-06-06 7:07 ` [PATCH v3 12/15] perf header: change FEAT_OP* macros David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 13/15] perf tool: add show_feature_header to perf_tool David Carrillo-Cisneros
2017-06-06 7:07 ` [PATCH v3 14/15] perf tools: add feature header record to pipe-mode David Carrillo-Cisneros
2017-06-06 7:07 ` David Carrillo-Cisneros [this message]
2017-06-08 11:54 ` [PATCH v3 15/15] perf header: add event desc to pipe-mode header Jiri Olsa
2017-06-13 4:23 ` David Carrillo-Cisneros
2017-06-06 12:35 ` [PATCH v3 00/15] perf tool: add meta-data header support for pipe-mode Jiri Olsa
2017-06-06 18:15 ` David Carrillo-Cisneros
2017-06-07 11:19 ` Jiri Olsa
2017-06-07 15:02 ` David Carrillo-Cisneros
2017-06-13 4:28 ` David Carrillo-Cisneros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170606070722.35213-16-davidcc@google.com \
--to=davidcc@google.com \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=hekuang@huawei.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=sque@chromium.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox