Commit 7320ad97 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf mem: Add -T/--data-type option to report subcommand

This is just a shortcut to have 'type' in the sort key and use more
compact output format like below.

  $ perf mem report -T
  ...
  #
  # Overhead       Samples  Memory access                            Snoop         TLB access              Data Type
  # ........  ............  .......................................  ............  ......................  .........
  #
      14.84%            22  L1 hit                                   None          L1 or L2 hit            (unknown)
       7.68%             8  LFB/MAB hit                              None          L1 or L2 hit            (unknown)
       7.17%             3  RAM hit                                  Hit           L2 miss                 (unknown)
       6.29%            12  L1 hit                                   None          L1 or L2 hit            (stack operation)
       4.85%             5  RAM hit                                  Hit           L1 or L2 hit            (unknown)
       3.97%             5  LFB/MAB hit                              None          L1 or L2 hit            struct psi_group_cpu
       3.18%             3  LFB/MAB hit                              None          L1 or L2 hit            (stack operation)
       2.58%             3  L1 hit                                   None          L1 or L2 hit            unsigned int
       2.36%             2  L1 hit                                   None          L1 or L2 hit            struct
       2.31%             2  L1 hit                                   None          L1 or L2 hit            struct psi_group_cpu
  ...

Users also can use their own sort keys and -T option makes sure it has
the 'type' sort key at the end.

  $ perf mem report -T -s mem
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20240731235505.710436-7-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2d99a991
...@@ -38,6 +38,7 @@ struct perf_mem { ...@@ -38,6 +38,7 @@ struct perf_mem {
bool data_page_size; bool data_page_size;
bool all_kernel; bool all_kernel;
bool all_user; bool all_user;
bool data_type;
int operation; int operation;
const char *cpu_list; const char *cpu_list;
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
...@@ -317,6 +318,8 @@ static char *get_sort_order(struct perf_mem *mem) ...@@ -317,6 +318,8 @@ static char *get_sort_order(struct perf_mem *mem)
if (mem->sort_key) if (mem->sort_key)
scnprintf(sort, sizeof(sort), "--sort=%s", mem->sort_key); scnprintf(sort, sizeof(sort), "--sort=%s", mem->sort_key);
else if (mem->data_type)
strcpy(sort, "--sort=mem,snoop,tlb,type");
/* /*
* there is no weight (cost) associated with stores, so don't print * there is no weight (cost) associated with stores, so don't print
* the column * the column
...@@ -336,6 +339,10 @@ static char *get_sort_order(struct perf_mem *mem) ...@@ -336,6 +339,10 @@ static char *get_sort_order(struct perf_mem *mem)
if (mem->data_page_size) if (mem->data_page_size)
strcat(sort, ",data_page_size"); strcat(sort, ",data_page_size");
/* make sure it has 'type' sort key even -s option is used */
if (mem->data_type && !strstr(sort, "type"))
strcat(sort, ",type");
return strdup(sort); return strdup(sort);
} }
...@@ -508,6 +515,8 @@ int cmd_mem(int argc, const char **argv) ...@@ -508,6 +515,8 @@ int cmd_mem(int argc, const char **argv)
" between columns '.' is reserved."), " between columns '.' is reserved."),
OPT_STRING('s', "sort", &mem.sort_key, "key[,key2...]", OPT_STRING('s', "sort", &mem.sort_key, "key[,key2...]",
sort_order_help), sort_order_help),
OPT_BOOLEAN('T', "type-profile", &mem.data_type,
"Show data-type profile result"),
OPT_PARENT(mem_options) OPT_PARENT(mem_options)
}; };
const char *const mem_subcommands[] = { "record", "report", NULL }; const char *const mem_subcommands[] = { "record", "report", NULL };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment