]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
perf sort: Add sort option for data page size
authorKan Liang <kan.liang@linux.intel.com>
Wed, 16 Dec 2020 18:57:58 +0000 (10:57 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 19 Dec 2020 20:52:24 +0000 (17:52 -0300)
Add a new sort option "data_page_size" for --mem-mode sort.  With this
option applied, perf can sort and report by sample's data page size.

Here is an example:

perf report --stdio --mem-mode
--sort=comm,symbol,phys_daddr,data_page_size

 # To display the perf.data header info, please use
 # --header/--header-only options.
 #
 #
 # Total Lost Samples: 0
 #
 # Samples: 9K of event 'mem-loads:uP'
 # Total weight : 9028
 # Sort order   : comm,symbol,phys_daddr,data_page_size
 #
 # Overhead  Command  Symbol                        Data Physical
 # Address
 # Data Page Size
 # ........  .......  ............................
 # ......................  ......................
 #
    11.19%  dtlb     [.] touch_buffer              [.] 0x00000003fec82ea8  4K
     8.61%  dtlb     [.] GetTickCount              [.] 0x00000003c4f2c8a8  4K
     4.52%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f58  4K
     4.33%  dtlb     [.] __gettimeofday            [.] 0x00000003fec82f48  4K
     4.32%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f78  4K
     4.28%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f50  4K
     4.23%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f70  4K
     4.11%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f68  4K
     4.00%  dtlb     [.] Calibrate                 [.] 0x00000003fec82f98  4K
     3.91%  dtlb     [.] Calibrate                 [.] 0x00000003fec82f90  4K
     3.43%  dtlb     [.] touch_buffer              [.] 0x00000003fec82e98  4K
     3.42%  dtlb     [.] touch_buffer              [.] 0x00000003fec82e90  4K
     0.09%  dtlb     [.] DoDependentLoads          [.] 0x000000036ea084c0  2M
     0.08%  dtlb     [.] DoDependentLoads          [.] 0x000000032b010b80  2M

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Stephane Eranian <eranian@google.com>
Cc: Will Deacon <will@kernel.org>
Link: http://lore.kernel.org/lkml/20201216185805.9981-3-kan.liang@linux.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/map_symbol.h
tools/perf/util/sort.c
tools/perf/util/sort.h

index d068103690ccc80b9fd445439b43afdde6a8d3a3..8f7f4e9605d89c1c757763b6116808ed0e45d9ee 100644 (file)
@@ -150,6 +150,7 @@ OPTIONS
        - 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
+       - data_page_size: the data page size 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 7feeaa07c77766fa933693969771540600a221be..a08fb9ea411bdc9f55a6096e9a173a8a51e405c8 100644 (file)
@@ -188,6 +188,9 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
                hists__new_col_len(hists, HISTC_MEM_PHYS_DADDR,
                                   unresolved_col_width + 4 + 2);
 
+               hists__new_col_len(hists, HISTC_MEM_DATA_PAGE_SIZE,
+                                  unresolved_col_width + 4 + 2);
+
        } else {
                symlen = unresolved_col_width + 4 + 2;
                hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
index df6c6eea0960567dbdc09d5cfeba29622ef92688..14f66330923d6563dd40e4acc06b8aef59d087fe 100644 (file)
@@ -56,6 +56,7 @@ enum hist_column {
        HISTC_MEM_DADDR_SYMBOL,
        HISTC_MEM_DADDR_DSO,
        HISTC_MEM_PHYS_DADDR,
+       HISTC_MEM_DATA_PAGE_SIZE,
        HISTC_MEM_LOCKED,
        HISTC_MEM_TLB,
        HISTC_MEM_LVL,
index 1ae32a81639c69e6606f3406ec41e5e7d31ef922..f841f3503cae61de55ce1b8dbe912b7b0f8e2f53 100644 (file)
@@ -2023,11 +2023,12 @@ static void ip__resolve_ams(struct thread *thread,
        ams->ms.sym = al.sym;
        ams->ms.map = al.map;
        ams->phys_addr = 0;
+       ams->data_page_size = 0;
 }
 
 static void ip__resolve_data(struct thread *thread,
                             u8 m, struct addr_map_symbol *ams,
-                            u64 addr, u64 phys_addr)
+                            u64 addr, u64 phys_addr, u64 daddr_page_size)
 {
        struct addr_location al;
 
@@ -2041,6 +2042,7 @@ static void ip__resolve_data(struct thread *thread,
        ams->ms.sym = al.sym;
        ams->ms.map = al.map;
        ams->phys_addr = phys_addr;
+       ams->data_page_size = daddr_page_size;
 }
 
 struct mem_info *sample__resolve_mem(struct perf_sample *sample,
@@ -2053,7 +2055,8 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
 
        ip__resolve_ams(al->thread, &mi->iaddr, sample->ip);
        ip__resolve_data(al->thread, al->cpumode, &mi->daddr,
-                        sample->addr, sample->phys_addr);
+                        sample->addr, sample->phys_addr,
+                        sample->data_page_size);
        mi->data_src.val = sample->data_src;
 
        return mi;
index 5b8ca93798e9ae00267c360de5525fb91a641eda..7d22ade082c8f891c5a718d1b549655621c841bb 100644 (file)
@@ -19,5 +19,6 @@ struct addr_map_symbol {
        u64           addr;
        u64           al_addr;
        u64           phys_addr;
+       u64           data_page_size;
 };
 #endif // __PERF_MAP_SYMBOL
index 7d87bfcffb3f6895bca95a374e48512d50769ed1..80907bc32683afa9c45b8670b9ce2895c6b086bb 100644 (file)
@@ -1462,6 +1462,35 @@ struct sort_entry sort_mem_phys_daddr = {
        .se_width_idx   = HISTC_MEM_PHYS_DADDR,
 };
 
+static int64_t
+sort__data_page_size_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+       uint64_t l = 0, r = 0;
+
+       if (left->mem_info)
+               l = left->mem_info->daddr.data_page_size;
+       if (right->mem_info)
+               r = right->mem_info->daddr.data_page_size;
+
+       return (int64_t)(r - l);
+}
+
+static int hist_entry__data_page_size_snprintf(struct hist_entry *he, char *bf,
+                                         size_t size, unsigned int width)
+{
+       char str[PAGE_SIZE_NAME_LEN];
+
+       return repsep_snprintf(bf, size, "%-*s", width,
+                              get_page_size_name(he->mem_info->daddr.data_page_size, str));
+}
+
+struct sort_entry sort_mem_data_page_size = {
+       .se_header      = "Data Page Size",
+       .se_cmp         = sort__data_page_size_cmp,
+       .se_snprintf    = hist_entry__data_page_size_snprintf,
+       .se_width_idx   = HISTC_MEM_DATA_PAGE_SIZE,
+};
+
 static int64_t
 sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
 {
@@ -1740,6 +1769,7 @@ static struct sort_dimension memory_sort_dimensions[] = {
        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),
+       DIM(SORT_MEM_DATA_PAGE_SIZE, "data_page_size", sort_mem_data_page_size),
 };
 
 #undef DIM
index 66d39c4cfe2b3213344720b5460b04de6edd69f7..e50f2b695bc43ab4258c60050391ddd3e5df6674 100644 (file)
@@ -255,6 +255,7 @@ enum sort_type {
        SORT_MEM_DCACHELINE,
        SORT_MEM_IADDR_SYMBOL,
        SORT_MEM_PHYS_DADDR,
+       SORT_MEM_DATA_PAGE_SIZE,
 };
 
 /*