perf report: Add support for PERF_SAMPLE_CODE_PAGE_SIZE
authorStephane Eranian <eranian@google.com>
Tue, 5 Jan 2021 19:57:51 +0000 (11:57 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 Jan 2021 17:34:20 +0000 (14:34 -0300)
Add a new sort dimension "code_page_size" for common sort.
With this option applied, perf can sort and report by sample's code page
size.

For example:

  # perf report --stdio --sort=comm,symbol,code_page_size
  # To display the perf.data header info, please use
  # --header/--header-only options.
  #
  #
  # Total Lost Samples: 0
  #
  # Samples: 3K of event 'mem-loads:uP'
  # Event count (approx.): 1470769
  #
  # Overhead  Command  Symbol                        Code Page Size IPC [IPC Coverage]
  # ........  .......  ............................  .............. ....................
  #
      69.56%  dtlb     [.] GetTickCount              4K              -   -
      17.93%  dtlb     [.] Calibrate                 4K              -   -
      11.40%  dtlb     [.] __gettimeofday            4K              -   -
  #

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

index 8f7f4e9605d89c1c757763b6116808ed0e45d9ee..e44045842c5c49f1848df90b03ee81a96d010007 100644 (file)
@@ -108,6 +108,7 @@ OPTIONS
        - period: Raw number of event count of sample
        - time: Separate the samples by time stamp with the resolution specified by
        --time-quantum (default 100ms). Specify with overhead and before it.
+       - code_page_size: the code page size of sampled code address (ip)
 
        By default, comm, dso and symbol keys are used.
        (i.e. --sort comm,dso,symbol)
index a08fb9ea411bdc9f55a6096e9a173a8a51e405c8..6d50379af90eef5fae4f8097d8ea550a5a2fad0b 100644 (file)
@@ -212,6 +212,7 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
                hists__new_col_len(hists, HISTC_TIME, 16);
        else
                hists__new_col_len(hists, HISTC_TIME, 12);
+       hists__new_col_len(hists, HISTC_CODE_PAGE_SIZE, 6);
 
        if (h->srcline) {
                len = MAX(strlen(h->srcline), strlen(sort_srcline.se_header));
@@ -718,6 +719,7 @@ __hists__add_entry(struct hists *hists,
                .cpumode = al->cpumode,
                .ip      = al->addr,
                .level   = al->level,
+               .code_page_size = sample->code_page_size,
                .stat = {
                        .nr_events = 1,
                        .period = sample->period,
index 14f66330923d6563dd40e4acc06b8aef59d087fe..361108533a56f3a186c688f106fe976eb72c6adf 100644 (file)
@@ -53,6 +53,7 @@ enum hist_column {
        HISTC_DSO_TO,
        HISTC_LOCAL_WEIGHT,
        HISTC_GLOBAL_WEIGHT,
+       HISTC_CODE_PAGE_SIZE,
        HISTC_MEM_DADDR_SYMBOL,
        HISTC_MEM_DADDR_DSO,
        HISTC_MEM_PHYS_DADDR,
index 80907bc32683afa9c45b8670b9ce2895c6b086bb..c00934c91b58554c1420830f444fc77f658784db 100644 (file)
@@ -1491,6 +1491,31 @@ struct sort_entry sort_mem_data_page_size = {
        .se_width_idx   = HISTC_MEM_DATA_PAGE_SIZE,
 };
 
+static int64_t
+sort__code_page_size_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+       uint64_t l = left->code_page_size;
+       uint64_t r = right->code_page_size;
+
+       return (int64_t)(r - l);
+}
+
+static int hist_entry__code_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->code_page_size, str));
+}
+
+struct sort_entry sort_code_page_size = {
+       .se_header      = "Code Page Size",
+       .se_cmp         = sort__code_page_size_cmp,
+       .se_snprintf    = hist_entry__code_page_size_snprintf,
+       .se_width_idx   = HISTC_CODE_PAGE_SIZE,
+};
+
 static int64_t
 sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
 {
@@ -1735,6 +1760,7 @@ static struct sort_dimension common_sort_dimensions[] = {
        DIM(SORT_CGROUP_ID, "cgroup_id", sort_cgroup_id),
        DIM(SORT_SYM_IPC_NULL, "ipc_null", sort_sym_ipc_null),
        DIM(SORT_TIME, "time", sort_time),
+       DIM(SORT_CODE_PAGE_SIZE, "code_page_size", sort_code_page_size),
 };
 
 #undef DIM
index e50f2b695bc43ab4258c60050391ddd3e5df6674..cab4172a6ec3c0859fa0f422c9f73a2eccfff0d6 100644 (file)
@@ -106,6 +106,7 @@ struct hist_entry {
        u64                     transaction;
        s32                     socket;
        s32                     cpu;
+       u64                     code_page_size;
        u8                      cpumode;
        u8                      depth;
 
@@ -229,6 +230,7 @@ enum sort_type {
        SORT_CGROUP_ID,
        SORT_SYM_IPC_NULL,
        SORT_TIME,
+       SORT_CODE_PAGE_SIZE,
 
        /* branch stack specific sort keys */
        __SORT_BRANCH_STACK,