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

perf mem report should support dumping physical addresses by applying -p
or --phys-data.

Signed-off-by: Kan Liang <kan.li...@intel.com>
---
 tools/perf/Documentation/perf-mem.txt |  4 ++
 tools/perf/builtin-mem.c              | 81 ++++++++++++++++++++++++-----------
 2 files changed, 61 insertions(+), 24 deletions(-)

diff --git a/tools/perf/Documentation/perf-mem.txt 
b/tools/perf/Documentation/perf-mem.txt
index 43310d8..929575a 100644
--- a/tools/perf/Documentation/perf-mem.txt
+++ b/tools/perf/Documentation/perf-mem.txt
@@ -48,6 +48,10 @@ OPTIONS
        option can be passed in record mode. It will be interpreted the same 
way as perf
        record.
 
+-p::
+--phys-data::
+       Record/Report/Dump sample physical addresses
+
 SEE ALSO
 --------
 linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index a81bdc2..8dc6b13 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -84,30 +84,60 @@ dump_raw_samples(struct perf_tool *tool,
        if (al.map != NULL)
                al.map->dso->hit = 1;
 
-       if (symbol_conf.field_sep) {
-               fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64
-                     "%s0x%"PRIx64"%s%s:%s\n";
+       if (mem->phys_addr) {
+               if (symbol_conf.field_sep) {
+                       fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s0x%016"PRIx64
+                             "%s%"PRIu64"%s0x%"PRIx64"%s%s:%s\n";
+               } else {
+                       fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
+                             "%s0x%016"PRIx64"%s%5"PRIu64"%s0x%06"PRIx64
+                             "%s%s:%s\n";
+                       symbol_conf.field_sep = " ";
+               }
+
+               printf(fmt,
+                       sample->pid,
+                       symbol_conf.field_sep,
+                       sample->tid,
+                       symbol_conf.field_sep,
+                       sample->ip,
+                       symbol_conf.field_sep,
+                       sample->addr,
+                       symbol_conf.field_sep,
+                       sample->phys_addr,
+                       symbol_conf.field_sep,
+                       sample->weight,
+                       symbol_conf.field_sep,
+                       sample->data_src,
+                       symbol_conf.field_sep,
+                       al.map ? (al.map->dso ? al.map->dso->long_name : "???") 
: "???",
+                       al.sym ? al.sym->name : "???");
        } else {
-               fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
-                     "%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n";
-               symbol_conf.field_sep = " ";
-       }
+               if (symbol_conf.field_sep) {
+                       fmt = "%d%s%d%s0x%"PRIx64"%s0x%"PRIx64"%s%"PRIu64
+                             "%s0x%"PRIx64"%s%s:%s\n";
+               } else {
+                       fmt = "%5d%s%5d%s0x%016"PRIx64"%s0x016%"PRIx64
+                             "%s%5"PRIu64"%s0x%06"PRIx64"%s%s:%s\n";
+                       symbol_conf.field_sep = " ";
+               }
 
-       printf(fmt,
-               sample->pid,
-               symbol_conf.field_sep,
-               sample->tid,
-               symbol_conf.field_sep,
-               sample->ip,
-               symbol_conf.field_sep,
-               sample->addr,
-               symbol_conf.field_sep,
-               sample->weight,
-               symbol_conf.field_sep,
-               sample->data_src,
-               symbol_conf.field_sep,
-               al.map ? (al.map->dso ? al.map->dso->long_name : "???") : "???",
-               al.sym ? al.sym->name : "???");
+               printf(fmt,
+                       sample->pid,
+                       symbol_conf.field_sep,
+                       sample->tid,
+                       symbol_conf.field_sep,
+                       sample->ip,
+                       symbol_conf.field_sep,
+                       sample->addr,
+                       symbol_conf.field_sep,
+                       sample->weight,
+                       symbol_conf.field_sep,
+                       sample->data_src,
+                       symbol_conf.field_sep,
+                       al.map ? (al.map->dso ? al.map->dso->long_name : "???") 
: "???",
+                       al.sym ? al.sym->name : "???");
+       }
 out_put:
        addr_location__put(&al);
        return 0;
@@ -147,7 +177,10 @@ static int report_raw_events(struct perf_mem *mem)
        if (ret < 0)
                goto out_delete;
 
-       printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
+       if (mem->phys_addr)
+               printf("# PID, TID, IP, ADDR, PHYS ADDR, LOCAL WEIGHT, DSRC, 
SYMBOL\n");
+       else
+               printf("# PID, TID, IP, ADDR, LOCAL WEIGHT, DSRC, SYMBOL\n");
 
        ret = perf_session__process_events(session);
 
@@ -301,7 +334,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix 
__maybe_unused)
                   "separator for columns, no spaces will be added"
                   " between columns '.' is reserved."),
        OPT_BOOLEAN('f', "force", &mem.force, "don't complain, do it"),
-       OPT_BOOLEAN('p', "phys-data", &mem.phys_addr, "Record/Report sample 
physical addresses"),
+       OPT_BOOLEAN('p', "phys-data", &mem.phys_addr, "Record/Report/Dump 
sample physical addresses"),
        OPT_END()
        };
        const char *const mem_subcommands[] = { "record", "report", NULL };
-- 
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/

Reply via email to