mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 <kan.liang@intel.com>
Subject: [PATCH 2/8] perf tools: add option to record sample physical address
Date: Wed,  6 Jan 2016 06:04:31 -0500	[thread overview]
Message-ID: <1452078277-15520-2-git-send-email-kan.liang@intel.com> (raw)
In-Reply-To: <1452078277-15520-1-git-send-email-kan.liang@intel.com>

From: Kan Liang <kan.liang@intel.com>

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 <kan.liang@intel.com>
---
 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


  reply	other threads:[~2016-01-06 18:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 11:04 [PATCH 1/8] perf: Add PERF_SAMPLE_PHYS_ADDR kan.liang
2016-01-06 11:04 ` kan.liang [this message]
2016-01-07  9:56   ` [PATCH 2/8] perf tools: add option to record sample physical address Jiri Olsa
2016-01-06 11:04 ` [PATCH 3/8] perf tools: add sort option phys_daddr kan.liang
2016-01-06 11:04 ` [PATCH 4/8] perf mem: add option phys-data to record physical address kan.liang
2016-01-06 11:04 ` [PATCH 5/8] perf mem: report physical addresses kan.liang
2016-01-07  8:27   ` Jiri Olsa
2016-01-06 11:04 ` [PATCH 6/8] perf mem: dump " kan.liang
2016-01-06 11:04 ` [PATCH 7/8] perf script: support physical addresses in script kan.liang
2016-01-07  9:54   ` Jiri Olsa
2016-01-06 11:04 ` [PATCH 8/8] perf test: add test case for PERF_SAMPLE_PHYS_ADDR kan.liang
2016-01-06 19:21 ` [PATCH 1/8] perf: Add PERF_SAMPLE_PHYS_ADDR Stephane Eranian
2016-01-07  8:33 ` Jiri Olsa
2016-01-07 15:55   ` Liang, Kan
2016-01-07 19:31     ` Jiri Olsa
2016-01-07 21:50 ` Stephane Eranian
2016-01-08 21:12   ` Liang, Kan

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=1452078277-15520-2-git-send-email-kan.liang@intel.com \
    --to=kan.liang@intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --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