From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753947AbdHUTOO (ORCPT ); Mon, 21 Aug 2017 15:14:14 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:35863 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753479AbdHUTON (ORCPT ); Mon, 21 Aug 2017 15:14:13 -0400 From: Stephane Eranian 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 Message-Id: <1503342849-2036-1-git-send-email-eranian@google.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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