Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf evsel: Add support for synthesized branch stack sample type

Allow for a synthesized branch stack to be added to samples. As with
synthesized call chains, the sample type cannot be changed because it is
needed to continue to parse events. So add and use helper function
evsel__has_br_stack() to indicate a branch stack, whether original or
synthesized.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20200429150751.12570-6-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
6cd2cbfc ec90e42c

+11 -1
+10
tools/perf/util/evsel.h
··· 417 417 evsel->synth_sample_type & PERF_SAMPLE_CALLCHAIN; 418 418 } 419 419 420 + static inline bool evsel__has_br_stack(const struct evsel *evsel) 421 + { 422 + /* 423 + * For reporting purposes, an evsel sample can have a recorded branch 424 + * stack or a branch stack synthesized from AUX area data. 425 + */ 426 + return evsel->core.attr.sample_type & PERF_SAMPLE_BRANCH_STACK || 427 + evsel->synth_sample_type & PERF_SAMPLE_BRANCH_STACK; 428 + } 429 + 420 430 struct perf_env *perf_evsel__env(struct evsel *evsel); 421 431 422 432 int perf_evsel__store_ids(struct evsel *evsel, struct evlist *evlist);
+1 -1
tools/perf/util/session.c
··· 1243 1243 if (evsel__has_callchain(evsel)) 1244 1244 callchain__printf(evsel, sample); 1245 1245 1246 - if (sample_type & PERF_SAMPLE_BRANCH_STACK) 1246 + if (evsel__has_br_stack(evsel)) 1247 1247 branch_stack__printf(sample, perf_evsel__has_branch_callstack(evsel)); 1248 1248 1249 1249 if (sample_type & PERF_SAMPLE_REGS_USER)