linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: acme@redhat.com, peterz@infradead.org, mingo@elte.hu,
	ak@linux.intel.com, kan.liang@intel.com, jolsa@redhat.com
Subject: [PATCH] perf record: enable multiplexing scaling via -R
Date: Mon, 21 Aug 2017 12:14:09 -0700	[thread overview]
Message-ID: <1503342849-2036-1-git-send-email-eranian@google.com> (raw)

This patch allows perf record to request that event
timing be recorded in each sample. The timing consists
of time_enabled and time_running. These two values are
used to compute the multiplexing correction, i.e.,
how long an event was actually measured by the hardware.

To activate, the user must use:
$ perf record -a -R ....

The patch works by forcing PERF_SAMPLE_READ in raw mode (-R),
i.e., reading of the event group in each sample.

The side effect is that both time_running and time_enable are
captured + an empty four byte RAW section. This way we leverage
an existing perf record mode and do not add yet another option.

With this patch, it is possible to evaluate the total number
of occurrences of each sampling event even when multiplexing is
active.

Signed-off-by: Stephane Eranian <eranian@google.com>
---
 tools/perf/Documentation/perf-record.txt | 2 ++
 tools/perf/util/evsel.c                  | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 9bdea047c5db..6a0bfd29bac9 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -270,6 +270,8 @@ OPTIONS
 -R::
 --raw-samples::
 Collect raw sample records from all opened counters (default for tracepoint counters).
+With this option, each sample includes at least: CPU, timestamp, time running/enabled
+(multiplexing scaling factor).
 
 -C::
 --cpu::
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 3735c9e0080d..3305c0b10161 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -852,6 +852,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 	attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1;
 	attr->inherit	    = !opts->no_inherit;
 	attr->write_backward = opts->overwrite ? 1 : 0;
+	attr->read_format   = PERF_FORMAT_TOTAL_TIME_ENABLED |
+			      PERF_FORMAT_TOTAL_TIME_RUNNING |
+			      PERF_FORMAT_ID;
 
 	perf_evsel__set_sample_bit(evsel, IP);
 	perf_evsel__set_sample_bit(evsel, TID);
@@ -945,6 +948,8 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
 		perf_evsel__set_sample_bit(evsel, TIME);
 		perf_evsel__set_sample_bit(evsel, RAW);
 		perf_evsel__set_sample_bit(evsel, CPU);
+		perf_evsel__set_sample_bit(evsel, ID);
+		perf_evsel__set_sample_bit(evsel, READ);
 	}
 
 	if (opts->sample_address)
-- 
2.7.4

             reply	other threads:[~2017-08-21 19:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 19:14 Stephane Eranian [this message]
2017-08-21 23:02 ` [PATCH] perf record: enable multiplexing scaling via -R Andi Kleen
2017-08-22  0:13   ` Stephane Eranian
2017-08-22  1:25     ` Andi Kleen
2017-08-22  7:03       ` Jiri Olsa
2017-08-22  7:24         ` Stephane Eranian
2017-08-28 19:27           ` Stephane Eranian
2017-08-28 20:41             ` Andi Kleen
2017-08-31  6:21               ` Stephane Eranian
2017-09-01  7:55                 ` Jiri Olsa
2017-09-01  7:59                 ` Jiri Olsa
2017-09-01  8:21                   ` Stephane Eranian
2017-09-01  8:31                     ` Jiri Olsa

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=1503342849-2036-1-git-send-email-eranian@google.com \
    --to=eranian@google.com \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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;
as well as URLs for NNTP newsgroup(s).