]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
perf sort: Add sort option for physical address
authorKan Liang <kan.liang@intel.com>
Tue, 29 Aug 2017 17:11:09 +0000 (13:11 -0400)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 1 Sep 2017 17:46:11 +0000 (14:46 -0300)
Add a new sort option "phys_daddr" for --mem-mode sort.  With this
option applied, perf can sort and report by sample's physical address.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1504026672-7304-3-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-report.txt
tools/perf/util/hist.c
tools/perf/util/hist.h
tools/perf/util/machine.c
tools/perf/util/session.c
tools/perf/util/sort.c
tools/perf/util/sort.h
tools/perf/util/symbol.h

index 9fa84617181e47e00a93529b6a91fca3d3fbe9c2..383a98d992ed5570564bf01f90cd9a2ba513e287 100644 (file)
@@ -137,6 +137,7 @@ OPTIONS
        - mem: type of memory access for the data at the time of the sample
        - snoop: type of snoop (if any) for the data at the time of the sample
        - dcacheline: the cacheline the data address is on at the time of the sample
+       - phys_daddr: physical address of data being executed on at the time of sample
 
        And the default sort keys are changed to local_weight, mem, sym, dso,
        symbol_daddr, dso_daddr, snoop, tlb, locked, see '--mem-mode'.
index 9453b2e270153cc02e98aff398671366af884ad2..e60d8d8ea4c23084240d0ca156205b102d8e789c 100644 (file)
@@ -167,6 +167,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
                        symlen = unresolved_col_width + 4 + 2;
                        hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
                }
+
+               hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR,
+                                  unresolved_col_width + 4 + 2);
+
        } else {
                symlen = unresolved_col_width + 4 + 2;
                hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
index ee3670a388df8f825fd6c79cb698e5fb6d7e5695..e60dda26a9207c08c0dd399e6d04588fb7302a2a 100644 (file)
@@ -47,6 +47,7 @@ enum hist_column {
        HISTC_GLOBAL_WEIGHT,
        HISTC_MEM_DADDR_SYMBOL,
        HISTC_MEM_DADDR_DSO,
+       HISTC_MEM_PHYS_DADDR,
        HISTC_MEM_LOCKED,
        HISTC_MEM_TLB,
        HISTC_MEM_LVL,
index 9eaa95302c864f85be22dcf121abeae2ef7ae129..df709363ef6902793376fee70027c41c04d06f7a 100644 (file)
@@ -1635,10 +1635,12 @@ static void ip__resolve_ams(struct thread *thread,
        ams->al_addr = al.addr;
        ams->sym = al.sym;
        ams->map = al.map;
+       ams->phys_addr = 0;
 }
 
 static void ip__resolve_data(struct thread *thread,
-                            u8 m, struct addr_map_symbol *ams, u64 addr)
+                            u8 m, struct addr_map_symbol *ams,
+                            u64 addr, u64 phys_addr)
 {
        struct addr_location al;
 
@@ -1658,6 +1660,7 @@ static void ip__resolve_data(struct thread *thread,
        ams->al_addr = al.addr;
        ams->sym = al.sym;
        ams->map = al.map;
+       ams->phys_addr = phys_addr;
 }
 
 struct mem_info *sample__resolve_mem(struct perf_sample *sample,
@@ -1669,7 +1672,8 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
                return NULL;
 
        ip__resolve_ams(al->thread, &mi->iaddr, sample->ip);
-       ip__resolve_data(al->thread, al->cpumode, &mi->daddr, sample->addr);
+       ip__resolve_data(al->thread, al->cpumode, &mi->daddr,
+                        sample->addr, sample->phys_addr);
        mi->data_src.val = sample->data_src;
 
        return mi;
index ac863691605f3cbbbc61513ab181961e46845ff0..a7ebd9fe8e40ee56f79a108c247d528571d8ff64 100644 (file)
@@ -1120,6 +1120,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);
 
index 12359bd986db3e2f5dc815e918a71e0835877d5d..eb3ab902a1c0869ad0b3431a82ba7bed49ec914d 100644 (file)
@@ -1315,6 +1315,47 @@ struct sort_entry sort_mem_dcacheline = {
        .se_width_idx   = HISTC_MEM_DCACHELINE,
 };
 
+static int64_t
+sort__phys_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+       uint64_t l = 0, r = 0;
+
+       if (left->mem_info)
+               l = left->mem_info->daddr.phys_addr;
+       if (right->mem_info)
+               r = right->mem_info->daddr.phys_addr;
+
+       return (int64_t)(r - l);
+}
+
+static int hist_entry__phys_daddr_snprintf(struct hist_entry *he, char *bf,
+                                          size_t size, unsigned int width)
+{
+       uint64_t addr = 0;
+       size_t ret = 0;
+       size_t len = BITS_PER_LONG / 4;
+
+       addr = he->mem_info->daddr.phys_addr;
+
+       ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", he->level);
+
+       ret += repsep_snprintf(bf + ret, size - ret, "%-#.*llx", len, addr);
+
+       ret += repsep_snprintf(bf + ret, size - ret, "%-*s", width - ret, "");
+
+       if (ret > width)
+               bf[width] = '\0';
+
+       return width;
+}
+
+struct sort_entry sort_mem_phys_daddr = {
+       .se_header      = "Data Physical Address",
+       .se_cmp         = sort__phys_daddr_cmp,
+       .se_snprintf    = hist_entry__phys_daddr_snprintf,
+       .se_width_idx   = HISTC_MEM_PHYS_DADDR,
+};
+
 static int64_t
 sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
 {
@@ -1547,6 +1588,7 @@ static struct sort_dimension memory_sort_dimensions[] = {
        DIM(SORT_MEM_LVL, "mem", sort_mem_lvl),
        DIM(SORT_MEM_SNOOP, "snoop", sort_mem_snoop),
        DIM(SORT_MEM_DCACHELINE, "dcacheline", sort_mem_dcacheline),
+       DIM(SORT_MEM_PHYS_DADDR, "phys_daddr", sort_mem_phys_daddr),
 };
 
 #undef DIM
index b7c75597e18fd226c190e8fbb81ef610690f8541..f36dc4980a6c78f3bc5a005d164f3d1a637053f3 100644 (file)
@@ -245,6 +245,7 @@ enum sort_type {
        SORT_MEM_SNOOP,
        SORT_MEM_DCACHELINE,
        SORT_MEM_IADDR_SYMBOL,
+       SORT_MEM_PHYS_DADDR,
 };
 
 /*
index d00a012cfdfb5d9227e5f53895448c6b9a4969da..2bd6a1f01a1cc5b5bb15ee0aae59ae921ebe2a86 100644 (file)
@@ -186,6 +186,7 @@ struct addr_map_symbol {
        struct symbol *sym;
        u64           addr;
        u64           al_addr;
+       u64           phys_addr;
 };
 
 struct branch_info {