perf tools: Add support for sorting on the iaddr
authorDon Zickus <dzickus@redhat.com>
Mon, 5 Oct 2015 18:06:07 +0000 (20:06 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Oct 2015 19:32:00 +0000 (16:32 -0300)
Sorting on 'symbol' gives to broad a resolution as it can cover a range
of IP address.  Use the iaddr instead to get proper sorting on IP
addresses.  Need to use the 'mem_sort' feature of perf record.

New sort option is: symbol_iaddr, header label is 'Code Symbol'.

  $ perf mem report --stdio -F +symbol_iaddr
  # Overhead       Samples  Code Symbol              Local Weight
  # ........  ............  ........................ ............
  #
      54.08%             1  [k] nmi_handle           192
       4.51%             1  [k] finish_task_switch   16
       3.66%             1  [.] malloc               13
       3.10%             1  [.] __strcoll_l          11

Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1444068369-20978-8-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/hist.h
tools/perf/util/sort.c
tools/perf/util/sort.h

index 8c20a8f6b214b1a05332b42ec213a304c233acb5..a48a2078d288f01b9edf10814571509803b674d1 100644 (file)
@@ -49,6 +49,7 @@ enum hist_column {
        HISTC_MEM_LVL,
        HISTC_MEM_SNOOP,
        HISTC_MEM_DCACHELINE,
+       HISTC_MEM_IADDR_SYMBOL,
        HISTC_TRANSACTION,
        HISTC_CYCLES,
        HISTC_NR_COLS, /* Last entry */
index 6b9556d298c94df6b0c0917882e28ef2e20d0ea2..ee94b728fca4b3a4e10df847ca7ee26e663fa844 100644 (file)
@@ -654,6 +654,35 @@ static int hist_entry__daddr_snprintf(struct hist_entry *he, char *bf,
                                         width);
 }
 
+static int64_t
+sort__iaddr_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+       uint64_t l = 0, r = 0;
+
+       if (left->mem_info)
+               l = left->mem_info->iaddr.addr;
+       if (right->mem_info)
+               r = right->mem_info->iaddr.addr;
+
+       return (int64_t)(r - l);
+}
+
+static int hist_entry__iaddr_snprintf(struct hist_entry *he, char *bf,
+                                   size_t size, unsigned int width)
+{
+       uint64_t addr = 0;
+       struct map *map = NULL;
+       struct symbol *sym = NULL;
+
+       if (he->mem_info) {
+               addr = he->mem_info->iaddr.addr;
+               map  = he->mem_info->iaddr.map;
+               sym  = he->mem_info->iaddr.sym;
+       }
+       return _hist_entry__sym_snprintf(map, sym, addr, he->level, bf, size,
+                                        width);
+}
+
 static int64_t
 sort__dso_daddr_cmp(struct hist_entry *left, struct hist_entry *right)
 {
@@ -1077,6 +1106,13 @@ struct sort_entry sort_mem_daddr_sym = {
        .se_width_idx   = HISTC_MEM_DADDR_SYMBOL,
 };
 
+struct sort_entry sort_mem_iaddr_sym = {
+       .se_header      = "Code Symbol",
+       .se_cmp         = sort__iaddr_cmp,
+       .se_snprintf    = hist_entry__iaddr_snprintf,
+       .se_width_idx   = HISTC_MEM_IADDR_SYMBOL,
+};
+
 struct sort_entry sort_mem_daddr_dso = {
        .se_header      = "Data Object",
        .se_cmp         = sort__dso_daddr_cmp,
@@ -1299,6 +1335,7 @@ static struct sort_dimension bstack_sort_dimensions[] = {
 
 static struct sort_dimension memory_sort_dimensions[] = {
        DIM(SORT_MEM_DADDR_SYMBOL, "symbol_daddr", sort_mem_daddr_sym),
+       DIM(SORT_MEM_IADDR_SYMBOL, "symbol_iaddr", sort_mem_iaddr_sym),
        DIM(SORT_MEM_DADDR_DSO, "dso_daddr", sort_mem_daddr_dso),
        DIM(SORT_MEM_LOCKED, "locked", sort_mem_locked),
        DIM(SORT_MEM_TLB, "tlb", sort_mem_tlb),
index c06b7574661320b502a3bf16a013108e9ff30944..33b3d30e18d391c97459fa76d6fb065a8fcde722 100644 (file)
@@ -201,6 +201,7 @@ enum sort_type {
        SORT_MEM_LVL,
        SORT_MEM_SNOOP,
        SORT_MEM_DCACHELINE,
+       SORT_MEM_IADDR_SYMBOL,
 };
 
 /*
This page took 0.02735 seconds and 5 git commands to generate.