linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 06/15] perf record: Add support for AUX area sampling
Date: Fri, 15 Nov 2019 14:42:16 +0200	[thread overview]
Message-ID: <20191115124225.5247-7-adrian.hunter@intel.com> (raw)
In-Reply-To: <20191115124225.5247-1-adrian.hunter@intel.com>

Add a 'perf record' option '--aux-sample' to request AUX area sampling. AUX
area sampling uses an overwriting buffer much like snapshot mode, so adjust
the AUX buffer mmapping accordingly. To make it easy to queue samples for
decoding, synthesize an ID index.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 tools/perf/Documentation/perf-record.txt |  6 ++++++
 tools/perf/builtin-record.c              | 21 ++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index ebcba1f95513..e216d7b529c9 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -433,6 +433,12 @@ can be specified in a string that follows this option:
 In Snapshot Mode trace data is captured only when signal SIGUSR2 is received
 and on exit if the above 'e' option is given.
 
+--aux-sample[=OPTIONS]::
+Select AUX area sampling. At least one of the events selected by the -e option
+must be an AUX area event. Samples on other events will be created containing
+data from the AUX area. Optionally sample size may be specified, otherwise it
+defaults to 4KiB.
+
 --proc-map-timeout::
 When processing pre-existing threads /proc/XXX/mmap, it may take a long time,
 because the file may be huge. A time out is needed in such cases.
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index b95c000c1ed9..d6383a557274 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -680,6 +680,11 @@ static int record__auxtrace_init(struct record *rec)
 	if (err)
 		return err;
 
+	err = auxtrace_parse_sample_options(rec->itr, rec->evlist, &rec->opts,
+					    rec->opts.auxtrace_sample_opts);
+	if (err)
+		return err;
+
 	return auxtrace_parse_filters(rec->evlist);
 }
 
@@ -752,6 +757,8 @@ static int record__mmap_evlist(struct record *rec,
 			       struct evlist *evlist)
 {
 	struct record_opts *opts = &rec->opts;
+	bool auxtrace_overwrite = opts->auxtrace_snapshot_mode ||
+				  opts->auxtrace_sample_mode;
 	char msg[512];
 
 	if (opts->affinity != PERF_AFFINITY_SYS)
@@ -759,7 +766,7 @@ static int record__mmap_evlist(struct record *rec,
 
 	if (evlist__mmap_ex(evlist, opts->mmap_pages,
 				 opts->auxtrace_mmap_pages,
-				 opts->auxtrace_snapshot_mode,
+				 auxtrace_overwrite,
 				 opts->nr_cblocks, opts->affinity,
 				 opts->mmap_flush, opts->comp_level) < 0) {
 		if (errno == EPERM) {
@@ -1046,6 +1053,7 @@ static int record__mmap_read_evlist(struct record *rec, struct evlist *evlist,
 		}
 
 		if (map->auxtrace_mmap.base && !rec->opts.auxtrace_snapshot_mode &&
+		    !rec->opts.auxtrace_sample_mode &&
 		    record__auxtrace_mmap_read(rec, map) != 0) {
 			rc = -1;
 			goto out;
@@ -1321,6 +1329,15 @@ static int record__synthesize(struct record *rec, bool tail)
 	if (err)
 		goto out;
 
+	/* Synthesize id_index before auxtrace_info */
+	if (rec->opts.auxtrace_sample_mode) {
+		err = perf_event__synthesize_id_index(tool,
+						      process_synthesized_event,
+						      session->evlist, machine);
+		if (err)
+			goto out;
+	}
+
 	if (rec->opts.full_auxtrace) {
 		err = perf_event__synthesize_auxtrace_info(rec->itr, tool,
 					session, process_synthesized_event);
@@ -2304,6 +2321,8 @@ static struct option __record_options[] = {
 	parse_clockid),
 	OPT_STRING_OPTARG('S', "snapshot", &record.opts.auxtrace_snapshot_opts,
 			  "opts", "AUX area tracing Snapshot Mode", ""),
+	OPT_STRING_OPTARG(0, "aux-sample", &record.opts.auxtrace_sample_opts,
+			  "opts", "sample AUX area", ""),
 	OPT_UINTEGER(0, "proc-map-timeout", &proc_map_timeout,
 			"per thread proc mmap processing timeout in ms"),
 	OPT_BOOLEAN(0, "namespaces", &record.opts.record_namespaces,
-- 
2.17.1


  parent reply	other threads:[~2019-11-15 12:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 12:42 [PATCH 00/15] perf tools: Add support for AUX area sampling Adrian Hunter
2019-11-15 12:42 ` [PATCH 01/15] perf tools: Add kernel AUX area sampling definitions Adrian Hunter
2019-11-21 13:57   ` Arnaldo Carvalho de Melo
2019-11-15 12:42 ` [PATCH 02/15] perf tools: Add AUX area sample parsing Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] perf tools: Add kernel AUX area sampling definitions tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 03/15] perf tools: Add a function to test for kernel support for AUX area sampling Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] perf record: " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 04/15] perf auxtrace: Move perf_evsel__find_pmu() Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 05/15] perf auxtrace: Add support for AUX area sample recording Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` Adrian Hunter [this message]
2019-11-23  8:15   ` [tip: perf/core] perf record: Add support for AUX area sampling tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 07/15] perf record: Add aux-sample-size config term Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 08/15] perf inject: Cut AUX area samples Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 09/15] perf auxtrace: Add support for dumping " Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 10/15] perf session: Add facility to peek at all events Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 11/15] perf auxtrace: Add support for queuing AUX area samples Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 12/15] perf pmu: When using default config, record which bits of config were changed by the user Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 13/15] perf intel-pt: Add support for recording AUX area samples Adrian Hunter
2019-11-21 14:28   ` Arnaldo Carvalho de Melo
2019-11-21 14:31     ` Arnaldo Carvalho de Melo
2019-11-21 14:31       ` Arnaldo Carvalho de Melo
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 14/15] perf intel-pt: Add support for decoding " Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-15 12:42 ` [PATCH 15/15] perf intel-bts: Does not support AUX area sampling Adrian Hunter
2019-11-23  8:15   ` [tip: perf/core] " tip-bot2 for Adrian Hunter
2019-11-21 13:03 ` [PATCH 00/15] perf tools: Add support for " Adrian Hunter

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=20191115124225.5247-7-adrian.hunter@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).