[PATCH 7/8] perf script: support physical addresses in script

2016-01-06 Thread kan . liang
From: Kan Liang 

perf script print out physical addresses by applying phys_addr.
Only display physical address when virtual address is selected. The
physical address will be printed out right after virtual address.

Signed-off-by: Kan Liang 
---
 tools/perf/builtin-script.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c298cdc..1e292a7 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -58,6 +58,7 @@ enum perf_output_field {
PERF_OUTPUT_IREGS   = 1U << 14,
PERF_OUTPUT_BRSTACK = 1U << 15,
PERF_OUTPUT_BRSTACKSYM  = 1U << 16,
+   PERF_OUTPUT_PHYS_ADDR   = 1U << 17,
 };
 
 struct output_option {
@@ -81,6 +82,7 @@ struct output_option {
{.str = "iregs", .field = PERF_OUTPUT_IREGS},
{.str = "brstack", .field = PERF_OUTPUT_BRSTACK},
{.str = "brstacksym", .field = PERF_OUTPUT_BRSTACKSYM},
+   {.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR},
 };
 
 /* default set to maintain compatibility with current format */
@@ -242,6 +244,12 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
   PERF_OUTPUT_ADDR, allow_user_set))
return -EINVAL;
 
+   if (PRINT_FIELD(PHYS_ADDR) && !PRINT_FIELD(ADDR)) {
+   pr_err("Display of sample physical address"
+  "but sample address is not selected.\n");
+   return -EINVAL;
+   }
+
if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) {
pr_err("Display of symbols requested but neither sample IP nor "
   "sample address\nis selected. Hence, no addresses to 
convert "
@@ -290,6 +298,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
PERF_OUTPUT_IREGS))
return -EINVAL;
 
+   if (PRINT_FIELD(PHYS_ADDR) &&
+   perf_evsel__do_check_stype(evsel, PERF_SAMPLE_PHYS_ADDR, 
"PHYS_ADDR",
+  PERF_OUTPUT_PHYS_ADDR, 
allow_user_set))
+   return -EINVAL;
+
return 0;
 }
 
@@ -653,6 +666,9 @@ static void process_event(struct perf_script *script 
__maybe_unused, union perf_
if (PRINT_FIELD(ADDR))
print_sample_addr(event, sample, thread, attr);
 
+   if (PRINT_FIELD(PHYS_ADDR))
+   printf("%16" PRIx64, sample->phys_addr);
+
if (PRINT_FIELD(IP)) {
if (!symbol_conf.use_callchain)
printf(" ");
@@ -1893,7 +1909,8 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
 "comma separated output fields prepend with 'type:'. "
 "Valid types: hw,sw,trace,raw. "
 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
-"addr,symoff,period,iregs,brstack,brstacksym,flags", 
parse_output_fields),
+
"addr,symoff,period,iregs,brstack,brstacksym,flags,phys_addr",
+parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", _wide,
"system-wide collection from all CPUs"),
OPT_STRING('S', "symbols", _conf.sym_list_str, 
"symbol[,symbol...]",
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/8] perf script: support physical addresses in script

2016-01-06 Thread kan . liang
From: Kan Liang 

perf script print out physical addresses by applying phys_addr.
Only display physical address when virtual address is selected. The
physical address will be printed out right after virtual address.

Signed-off-by: Kan Liang 
---
 tools/perf/builtin-script.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c298cdc..1e292a7 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -58,6 +58,7 @@ enum perf_output_field {
PERF_OUTPUT_IREGS   = 1U << 14,
PERF_OUTPUT_BRSTACK = 1U << 15,
PERF_OUTPUT_BRSTACKSYM  = 1U << 16,
+   PERF_OUTPUT_PHYS_ADDR   = 1U << 17,
 };
 
 struct output_option {
@@ -81,6 +82,7 @@ struct output_option {
{.str = "iregs", .field = PERF_OUTPUT_IREGS},
{.str = "brstack", .field = PERF_OUTPUT_BRSTACK},
{.str = "brstacksym", .field = PERF_OUTPUT_BRSTACKSYM},
+   {.str = "phys_addr", .field = PERF_OUTPUT_PHYS_ADDR},
 };
 
 /* default set to maintain compatibility with current format */
@@ -242,6 +244,12 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
   PERF_OUTPUT_ADDR, allow_user_set))
return -EINVAL;
 
+   if (PRINT_FIELD(PHYS_ADDR) && !PRINT_FIELD(ADDR)) {
+   pr_err("Display of sample physical address"
+  "but sample address is not selected.\n");
+   return -EINVAL;
+   }
+
if (PRINT_FIELD(SYM) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) {
pr_err("Display of symbols requested but neither sample IP nor "
   "sample address\nis selected. Hence, no addresses to 
convert "
@@ -290,6 +298,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
PERF_OUTPUT_IREGS))
return -EINVAL;
 
+   if (PRINT_FIELD(PHYS_ADDR) &&
+   perf_evsel__do_check_stype(evsel, PERF_SAMPLE_PHYS_ADDR, 
"PHYS_ADDR",
+  PERF_OUTPUT_PHYS_ADDR, 
allow_user_set))
+   return -EINVAL;
+
return 0;
 }
 
@@ -653,6 +666,9 @@ static void process_event(struct perf_script *script 
__maybe_unused, union perf_
if (PRINT_FIELD(ADDR))
print_sample_addr(event, sample, thread, attr);
 
+   if (PRINT_FIELD(PHYS_ADDR))
+   printf("%16" PRIx64, sample->phys_addr);
+
if (PRINT_FIELD(IP)) {
if (!symbol_conf.use_callchain)
printf(" ");
@@ -1893,7 +1909,8 @@ int cmd_script(int argc, const char **argv, const char 
*prefix __maybe_unused)
 "comma separated output fields prepend with 'type:'. "
 "Valid types: hw,sw,trace,raw. "
 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
-"addr,symoff,period,iregs,brstack,brstacksym,flags", 
parse_output_fields),
+
"addr,symoff,period,iregs,brstack,brstacksym,flags,phys_addr",
+parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", _wide,
"system-wide collection from all CPUs"),
OPT_STRING('S', "symbols", _conf.sym_list_str, 
"symbol[,symbol...]",
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/