Skip to content

Commit 81e57de

Browse files
namhyungacmel
authored andcommitted
perf report: Support data type profiling
Enable type annotation when the 'type' sort key is used. It shows type of variables the samples access at the moment. Users can see which types are accessed frequently. $ perf report -s dso,type --stdio ... # Overhead Shared Object Data Type # ........ ................. ......... # 35.47% [kernel.kallsyms] (unknown) 1.62% [kernel.kallsyms] struct sched_entry 1.23% [kernel.kallsyms] struct cfs_rq 0.83% [kernel.kallsyms] struct task_struct 0.34% [kernel.kallsyms] struct list_head 0.30% [kernel.kallsyms] struct mem_cgroup ... Committer testing: With the perf.data file collected in the previous cset: # perf report --stdio -s type # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 4 of event 'cpu_atom/mem-loads,ldlat=30/P' # Event count (approx.): 7 # # Overhead Data Type # ........ ......... # 42.86% struct list_head 42.86% (unknown) 14.29% char # # (Tip: To record callchains for each sample: perf record -g) # # perf report --stdio -s dso,type # To display the perf.data header info, please use --header/--header-only options. # # # Total Lost Samples: 0 # # Samples: 4 of event 'cpu_atom/mem-loads,ldlat=30/P' # Event count (approx.): 7 # # Overhead Shared Object Data Type # ........ .................... ......... # 42.86% [kernel.kallsyms] struct list_head 28.57% libc.so.6 (unknown) 14.29% [kernel.kallsyms] char 14.29% ld-linux-x86-64.so.2 (unknown) # # (Tip: Save output of perf stat using: perf stat record <target workload>) # # Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: linux-toolchains@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Link: https://lore.kernel.org/r/20231213001323.718046-10-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 2f2c41b commit 81e57de

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

tools/perf/builtin-report.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct report {
9696
bool stitch_lbr;
9797
bool disable_order;
9898
bool skip_empty;
99+
bool data_type;
99100
int max_stack;
100101
struct perf_read_values show_threads_values;
101102
const char *pretty_printing_style;
@@ -170,7 +171,7 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
170171
struct mem_info *mi;
171172
struct branch_info *bi;
172173

173-
if (!ui__has_annotation() && !rep->symbol_ipc)
174+
if (!ui__has_annotation() && !rep->symbol_ipc && !rep->data_type)
174175
return 0;
175176

176177
if (sort__mode == SORT_MODE__BRANCH) {
@@ -1639,6 +1640,16 @@ int cmd_report(int argc, const char **argv)
16391640
sort_order = NULL;
16401641
}
16411642

1643+
if (sort_order && strstr(sort_order, "type")) {
1644+
report.data_type = true;
1645+
annotate_opts.annotate_src = false;
1646+
1647+
#ifndef HAVE_DWARF_GETLOCATIONS_SUPPORT
1648+
pr_err("Error: Data type profiling is disabled due to missing DWARF support\n");
1649+
goto error;
1650+
#endif
1651+
}
1652+
16421653
if (strcmp(input_name, "-") != 0)
16431654
setup_browser(true);
16441655
else
@@ -1697,7 +1708,7 @@ int cmd_report(int argc, const char **argv)
16971708
* so don't allocate extra space that won't be used in the stdio
16981709
* implementation.
16991710
*/
1700-
if (ui__has_annotation() || report.symbol_ipc ||
1711+
if (ui__has_annotation() || report.symbol_ipc || report.data_type ||
17011712
report.total_cycles_mode) {
17021713
ret = symbol__annotation_init();
17031714
if (ret < 0)

0 commit comments

Comments
 (0)