From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Adrian Hunter <adrian.hunter@intel.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 21/64] perf session: Add instruction tracing options
Date: Tue, 28 Apr 2015 10:30:13 -0300 [thread overview]
Message-ID: <1430227856-25825-22-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1430227856-25825-1-git-send-email-acme@kernel.org>
From: Adrian Hunter <adrian.hunter@intel.com>
It is assumed that AUX area decoding will synthesize events for
consumption by other tools.
At this time, the main use of AUX area tracing will be to capture
instruction trace (aka processor trace) data.
The nature of instruction tracing suggests the initial inclusion of
options for "instructions" and "branches" events, but more could be
added as needed.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1428594864-29309-10-git-send-email-adrian.hunter@intel.com
[ Added ref to tools/perf/Documentation/perf-script.txt describing what is parsed ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/auxtrace.c | 136 +++++++++++++++++++++++++++++++++++++++++++++
tools/perf/util/auxtrace.h | 43 ++++++++++++++
tools/perf/util/session.h | 2 +
3 files changed, 181 insertions(+)
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 2cafea2ec015..db40d6c6c010 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -37,6 +37,7 @@
#include "event.h"
#include "debug.h"
+#include "parse-options.h"
int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
struct auxtrace_mmap_params *mp,
@@ -200,6 +201,141 @@ out_free:
return err;
}
+#define PERF_ITRACE_DEFAULT_PERIOD_TYPE PERF_ITRACE_PERIOD_NANOSECS
+#define PERF_ITRACE_DEFAULT_PERIOD 100000
+#define PERF_ITRACE_DEFAULT_CALLCHAIN_SZ 16
+#define PERF_ITRACE_MAX_CALLCHAIN_SZ 1024
+
+void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts)
+{
+ synth_opts->instructions = true;
+ synth_opts->branches = true;
+ synth_opts->errors = true;
+ synth_opts->period_type = PERF_ITRACE_DEFAULT_PERIOD_TYPE;
+ synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
+ synth_opts->callchain_sz = PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
+}
+
+/*
+ * Please check tools/perf/Documentation/perf-script.txt for information
+ * about the options parsed here, which is introduced after this cset,
+ * when support in 'perf script' for these options is introduced.
+ */
+int itrace_parse_synth_opts(const struct option *opt, const char *str,
+ int unset)
+{
+ struct itrace_synth_opts *synth_opts = opt->value;
+ const char *p;
+ char *endptr;
+
+ synth_opts->set = true;
+
+ if (unset) {
+ synth_opts->dont_decode = true;
+ return 0;
+ }
+
+ if (!str) {
+ itrace_synth_opts__set_default(synth_opts);
+ return 0;
+ }
+
+ for (p = str; *p;) {
+ switch (*p++) {
+ case 'i':
+ synth_opts->instructions = true;
+ while (*p == ' ' || *p == ',')
+ p += 1;
+ if (isdigit(*p)) {
+ synth_opts->period = strtoull(p, &endptr, 10);
+ p = endptr;
+ while (*p == ' ' || *p == ',')
+ p += 1;
+ switch (*p++) {
+ case 'i':
+ synth_opts->period_type =
+ PERF_ITRACE_PERIOD_INSTRUCTIONS;
+ break;
+ case 't':
+ synth_opts->period_type =
+ PERF_ITRACE_PERIOD_TICKS;
+ break;
+ case 'm':
+ synth_opts->period *= 1000;
+ /* Fall through */
+ case 'u':
+ synth_opts->period *= 1000;
+ /* Fall through */
+ case 'n':
+ if (*p++ != 's')
+ goto out_err;
+ synth_opts->period_type =
+ PERF_ITRACE_PERIOD_NANOSECS;
+ break;
+ case '\0':
+ goto out;
+ default:
+ goto out_err;
+ }
+ }
+ break;
+ case 'b':
+ synth_opts->branches = true;
+ break;
+ case 'e':
+ synth_opts->errors = true;
+ break;
+ case 'd':
+ synth_opts->log = true;
+ break;
+ case 'c':
+ synth_opts->branches = true;
+ synth_opts->calls = true;
+ break;
+ case 'r':
+ synth_opts->branches = true;
+ synth_opts->returns = true;
+ break;
+ case 'g':
+ synth_opts->instructions = true;
+ synth_opts->callchain = true;
+ synth_opts->callchain_sz =
+ PERF_ITRACE_DEFAULT_CALLCHAIN_SZ;
+ while (*p == ' ' || *p == ',')
+ p += 1;
+ if (isdigit(*p)) {
+ unsigned int val;
+
+ val = strtoul(p, &endptr, 10);
+ p = endptr;
+ if (!val || val > PERF_ITRACE_MAX_CALLCHAIN_SZ)
+ goto out_err;
+ synth_opts->callchain_sz = val;
+ }
+ break;
+ case ' ':
+ case ',':
+ break;
+ default:
+ goto out_err;
+ }
+ }
+out:
+ if (synth_opts->instructions) {
+ if (!synth_opts->period_type)
+ synth_opts->period_type =
+ PERF_ITRACE_DEFAULT_PERIOD_TYPE;
+ if (!synth_opts->period)
+ synth_opts->period = PERF_ITRACE_DEFAULT_PERIOD;
+ }
+
+ return 0;
+
+out_err:
+ pr_err("Bad Instruction Tracing options '%s'\n", str);
+ return -EINVAL;
+}
+
int auxtrace_mmap__read(struct auxtrace_mmap *mm, struct auxtrace_record *itr,
struct perf_tool *tool, process_auxtrace_t fn)
{
diff --git a/tools/perf/util/auxtrace.h b/tools/perf/util/auxtrace.h
index 199fc27b3954..6355315a91fb 100644
--- a/tools/perf/util/auxtrace.h
+++ b/tools/perf/util/auxtrace.h
@@ -29,9 +29,49 @@ union perf_event;
struct perf_session;
struct perf_evlist;
struct perf_tool;
+struct option;
struct record_opts;
struct auxtrace_info_event;
+enum itrace_period_type {
+ PERF_ITRACE_PERIOD_INSTRUCTIONS,
+ PERF_ITRACE_PERIOD_TICKS,
+ PERF_ITRACE_PERIOD_NANOSECS,
+};
+
+/**
+ * struct itrace_synth_opts - AUX area tracing synthesis options.
+ * @set: indicates whether or not options have been set
+ * @inject: indicates the event (not just the sample) must be fully synthesized
+ * because 'perf inject' will write it out
+ * @instructions: whether to synthesize 'instructions' events
+ * @branches: whether to synthesize 'branches' events
+ * @errors: whether to synthesize decoder error events
+ * @dont_decode: whether to skip decoding entirely
+ * @log: write a decoding log
+ * @calls: limit branch samples to calls (can be combined with @returns)
+ * @returns: limit branch samples to returns (can be combined with @calls)
+ * @callchain: add callchain to 'instructions' events
+ * @callchain_sz: maximum callchain size
+ * @period: 'instructions' events period
+ * @period_type: 'instructions' events period type
+ */
+struct itrace_synth_opts {
+ bool set;
+ bool inject;
+ bool instructions;
+ bool branches;
+ bool errors;
+ bool dont_decode;
+ bool log;
+ bool calls;
+ bool returns;
+ bool callchain;
+ unsigned int callchain_sz;
+ unsigned long long period;
+ enum itrace_period_type period_type;
+};
+
/**
* struct auxtrace - session callbacks to allow AUX area data decoding.
* @process_event: lets the decoder see all session events
@@ -186,6 +226,9 @@ int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
struct perf_tool *tool,
struct perf_session *session,
perf_event__handler_t process);
+int itrace_parse_synth_opts(const struct option *opt, const char *str,
+ int unset);
+void itrace_synth_opts__set_default(struct itrace_synth_opts *synth_opts);
static inline int auxtrace__process_event(struct perf_session *session,
union perf_event *event,
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 8a69d3bfafdf..9ed51353a3d7 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -16,12 +16,14 @@ struct ip_callchain;
struct thread;
struct auxtrace;
+struct itrace_synth_opts;
struct perf_session {
struct perf_header header;
struct machines machines;
struct perf_evlist *evlist;
struct auxtrace *auxtrace;
+ struct itrace_synth_opts *itrace_synth_opts;
struct trace_event tevent;
bool repipe;
bool one_mmap;
--
1.9.3
next prev parent reply other threads:[~2015-04-28 13:33 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 13:29 [GIT PULL 00/64] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 01/64] perf hists: Get rid of position field from struct hist_entry Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 02/64] perf diff: Make hist_entry_diff fields union Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 03/64] perf data: Show error message when conversion failed Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 04/64] tools lib traceevent: Add alias field to struct format_field Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 05/64] tools build: No need to make libapi for perf explicitly Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 06/64] tools build: Fix Makefile(s) to properly invoke tools build Arnaldo Carvalho de Melo
2015-04-28 13:29 ` [PATCH 07/64] perf tests: Add build tests for building perf from kernel source root and tools Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 08/64] perf data: Switch to multiple cpu stream files Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 09/64] perf data: Enable stream flush within processing Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 10/64] perf data: Add support for setting ordered_events queue size Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 11/64] perf data: Fix duplicate field names and avoid reserved keywords Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 12/64] perf data: Fix signedness of value Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 13/64] perf header: Add AUX area tracing feature Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 14/64] perf evlist: Add support for mmapping an AUX area buffer Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 15/64] perf tools: Add user events for AUX area tracing Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 16/64] perf auxtrace: Add support for AUX area recording Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 17/64] perf record: Add basic AUX area tracing support Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 18/64] perf record: Extend -m option for AUX area tracing mmap pages Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 19/64] perf tools: Add a user event for AUX area tracing errors Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 20/64] perf session: Add hooks to allow transparent decoding of AUX area tracing data Arnaldo Carvalho de Melo
2015-04-28 13:30 ` Arnaldo Carvalho de Melo [this message]
2015-04-28 13:30 ` [PATCH 22/64] perf auxtrace: Add helpers for AUX area tracing errors Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 23/64] perf auxtrace: Add helpers for queuing AUX area tracing data Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 24/64] perf auxtrace: Add a heap for sorting AUX area tracing queues Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 25/64] perf auxtrace: Add processing for AUX area tracing events Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 26/64] perf auxtrace: Add a hashtable for caching Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 27/64] perf tools: Add member to struct dso for an instruction cache Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 28/64] perf script: Add Instruction Tracing support Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 29/64] perf inject: Re-pipe AUX area tracing events Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 30/64] perf inject: Add Instruction Tracing support Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 31/64] perf script: Add field option 'flags' to print sample flags Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 32/64] perf tools: Add aux_watermark member of struct perf_event_attr Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 33/64] perf tools: Add parse_events_error interface Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 34/64] perf tools: Add flex support for parse_events_error Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 35/64] perf tools: Always bail out when config_attr function fails Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 36/64] perf tools: Change parse_events_add_pmu interface Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 37/64] perf tools: Add location to pmu event terms Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 38/64] perf tools: Add term support for parse_events_error Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 39/64] perf tools: Add static terms " Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 40/64] perf tools: Add tracepoint " Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 41/64] perf tools: Add symbolic events " Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 42/64] perf probe: Make --funcs option exclusive Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 43/64] perf probe: Remove all probes matches given pattern at once Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 44/64] perf trace: Fix --filter-pids OPTION description Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 45/64] perf trace: Clarify that -e is about syscalls, not perf events in general Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 46/64] perf stat: Fix metrics calculation with event qualifiers Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 47/64] perf stat: Change metrics context calculation Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 48/64] perf stat: Add metrics support for exclude_hv Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 49/64] perf stat: Add metrics support for exclude_(host|guest) Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 50/64] perf stat: Add metrics support for exclude_idle Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 51/64] perf tools: Document --children option in more detail Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 52/64] perf tools: Move TUI-specific fields into unnamed union Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 53/64] perf tools: Move init_have_children field to the " Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 54/64] perf hists browser: Fix possible memory leak Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 55/64] perf hists browser: Save hist_browser_timer pointer in hist_browser Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 56/64] perf hists browser: Save pstack in the hist_browser Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 57/64] perf hists browser: Save perf_session_env " Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 58/64] perf hists browser: Split popup menu actions Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 59/64] perf hists browser: Split popup menu actions - part 2 Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 60/64] perf tools: Introduce pstack_peek() Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 61/64] perf hists browser: Simplify zooming code using pstack_peek() Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 62/64] perf tools: Move TUI-specific fields out of map_symbol Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 63/64] perf tools: Use getconf to determine number of online CPUs Arnaldo Carvalho de Melo
2015-04-28 13:30 ` [PATCH 64/64] perf bench numa: Show more stats of particular threads in verbose mode Arnaldo Carvalho de Melo
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=1430227856-25825-22-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@gmail.com \
--cc=peterz@infradead.org \
/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
Powered by JetHome