From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752746AbcAFSXq (ORCPT ); Wed, 6 Jan 2016 13:23:46 -0500 Received: from mga03.intel.com ([134.134.136.65]:6361 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323AbcAFSXT (ORCPT ); Wed, 6 Jan 2016 13:23:19 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,530,1444719600"; d="scan'208";a="629031464" From: kan.liang@intel.com To: peterz@infradead.org, acme@kernel.org Cc: eranian@google.com, ak@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH 2/8] perf tools: add option to record sample physical address Date: Wed, 6 Jan 2016 06:04:31 -0500 Message-Id: <1452078277-15520-2-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1452078277-15520-1-git-send-email-kan.liang@intel.com> References: <1452078277-15520-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang Add new option --phys-data for perf record to record sample physical address. Once the option is applied, it implies that --data option is also applied to record sample virtual address. Signed-off-by: Kan Liang --- tools/perf/Documentation/perf-record.txt | 6 +++++- tools/perf/builtin-record.c | 10 +++++++++- tools/perf/perf.h | 1 + tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 17 +++++++++++++++++ tools/perf/util/session.c | 3 +++ 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 3a1a32f..e40c9df 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -181,7 +181,11 @@ OPTIONS -d:: --data:: - Record the sample addresses. + Record the sample virtual addresses. + +--phys-data:: + Record the sample physical addresses which implies + the virtual address is also recorded. -T:: --timestamp:: diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 9c5cdc2c4..b552f50 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1082,7 +1082,8 @@ struct option __record_options[] = { OPT_BOOLEAN('q', "quiet", &quiet, "don't print any message"), OPT_BOOLEAN('s', "stat", &record.opts.inherit_stat, "per thread counts"), - OPT_BOOLEAN('d', "data", &record.opts.sample_address, "Record the sample addresses"), + OPT_BOOLEAN('d', "data", &record.opts.sample_address, "Record the sample virtual addresses"), + OPT_BOOLEAN(0, "phys-data", &record.opts.sample_phys_addr, "Record the sample physical addresses"), OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time, &record.opts.sample_time_set, "Record the sample timestamps"), @@ -1223,6 +1224,13 @@ int cmd_record(int argc, const char **argv, const char *prefix __maybe_unused) goto out_symbol_exit; } + /* + * Record the sample physical addr which also implies + * the virtual addr is recorded. + */ + if (rec->opts.sample_phys_addr) + rec->opts.sample_address = true; + if (rec->opts.target.tid && !rec->opts.no_inherit_set) rec->opts.no_inherit = true; diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 90129ac..edfb938 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -49,6 +49,7 @@ struct record_opts { bool no_samples; bool raw_samples; bool sample_address; + bool sample_phys_addr; bool sample_weight; bool sample_time; bool sample_time_set; diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index b7ffb7e..0715883 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -190,6 +190,7 @@ struct perf_sample { u32 cpu; u32 raw_size; u64 data_src; + u64 phys_addr; u32 flags; u16 insn_len; void *raw_data; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 544e440..32f7b4f 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -838,6 +838,9 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) if (opts->sample_address) perf_evsel__set_sample_bit(evsel, DATA_SRC); + if (opts->sample_phys_addr) + perf_evsel__set_sample_bit(evsel, PHYS_ADDR); + if (opts->no_buffering) { attr->watermark = 0; attr->wakeup_events = 1; @@ -1847,6 +1850,12 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, array++; } + data->phys_addr = 0; + if (type & PERF_SAMPLE_PHYS_ADDR) { + data->phys_addr = *array; + array++; + } + data->transaction = 0; if (type & PERF_SAMPLE_TRANSACTION) { OVERFLOW_CHECK_u64(array); @@ -1963,6 +1972,9 @@ size_t perf_event__sample_event_size(const struct perf_sample *sample, u64 type, if (type & PERF_SAMPLE_DATA_SRC) result += sizeof(u64); + if (type & PERF_SAMPLE_PHYS_ADDR) + result += sizeof(u64); + if (type & PERF_SAMPLE_TRANSACTION) result += sizeof(u64); @@ -2149,6 +2161,11 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, array++; } + if (type & PERF_SAMPLE_PHYS_ADDR) { + *array = sample->phys_addr; + array++; + } + if (type & PERF_SAMPLE_TRANSACTION) { *array = sample->transaction; array++; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index d5636ba..670ff4f 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1122,6 +1122,9 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event, if (sample_type & PERF_SAMPLE_DATA_SRC) printf(" . data_src: 0x%"PRIx64"\n", sample->data_src); + if (sample_type & PERF_SAMPLE_PHYS_ADDR) + printf(" .. phys_addr: 0x%"PRIx64"\n", sample->phys_addr); + if (sample_type & PERF_SAMPLE_TRANSACTION) printf("... transaction: %" PRIx64 "\n", sample->transaction); -- 1.8.3.1