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

perf auxtrace: Add option to synthesize branch stack for regular events

There is an existing option to synthesize branch stacks for synthesized
events. Add a new option to synthesize branch stacks for regular events.

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-5-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
ec90e42c cf888e08

+15 -5
+1
tools/perf/Documentation/itrace.txt
··· 12 12 g synthesize a call chain (use with i or x) 13 13 G synthesize a call chain on existing event records 14 14 l synthesize last branch entries (use with i or x) 15 + L synthesize last branch entries on existing event records 15 16 s skip initial number of events 16 17 17 18 The default is all events i.e. the same as --itrace=ibxwpe,
+2 -1
tools/perf/builtin-inject.c
··· 684 684 685 685 perf_header__clear_feat(&session->header, 686 686 HEADER_AUXTRACE); 687 - if (inject->itrace_synth_opts.last_branch) 687 + if (inject->itrace_synth_opts.last_branch || 688 + inject->itrace_synth_opts.add_last_branch) 688 689 perf_header__set_feat(&session->header, 689 690 HEADER_BRANCH_STACK); 690 691 evsel = perf_evlist__id2evsel_strict(session->evlist,
+3 -2
tools/perf/builtin-report.c
··· 349 349 !session->itrace_synth_opts->set)) 350 350 sample_type |= PERF_SAMPLE_CALLCHAIN; 351 351 352 - if (session->itrace_synth_opts->last_branch) 352 + if (session->itrace_synth_opts->last_branch || 353 + session->itrace_synth_opts->add_last_branch) 353 354 sample_type |= PERF_SAMPLE_BRANCH_STACK; 354 355 355 356 if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) { ··· 1394 1393 goto error; 1395 1394 } 1396 1395 1397 - if (itrace_synth_opts.last_branch) 1396 + if (itrace_synth_opts.last_branch || itrace_synth_opts.add_last_branch) 1398 1397 has_br_stack = true; 1399 1398 1400 1399 if (has_br_stack && branch_call_mode)
+5 -1
tools/perf/util/auxtrace.c
··· 1464 1464 synth_opts->callchain_sz = val; 1465 1465 } 1466 1466 break; 1467 + case 'L': 1467 1468 case 'l': 1468 - synth_opts->last_branch = true; 1469 + if (p[-1] == 'L') 1470 + synth_opts->add_last_branch = true; 1471 + else 1472 + synth_opts->last_branch = true; 1469 1473 synth_opts->last_branch_sz = 1470 1474 PERF_ITRACE_DEFAULT_LAST_BRANCH_SZ; 1471 1475 while (*p == ' ' || *p == ',')
+2
tools/perf/util/auxtrace.h
··· 77 77 * @add_callchain: add callchain to existing event records 78 78 * @thread_stack: feed branches to the thread_stack 79 79 * @last_branch: add branch context to 'instruction' events 80 + * @add_last_branch: add branch context to existing event records 80 81 * @callchain_sz: maximum callchain size 81 82 * @last_branch_sz: branch context size 82 83 * @period: 'instructions' events period ··· 106 105 bool add_callchain; 107 106 bool thread_stack; 108 107 bool last_branch; 108 + bool add_last_branch; 109 109 unsigned int callchain_sz; 110 110 unsigned int last_branch_sz; 111 111 unsigned long long period;
+2 -1
tools/perf/util/s390-cpumsf.c
··· 1079 1079 itops->pwr_events || itops->errors || 1080 1080 itops->dont_decode || itops->calls || itops->returns || 1081 1081 itops->callchain || itops->thread_stack || 1082 - itops->last_branch || itops->add_callchain; 1082 + itops->last_branch || itops->add_callchain || 1083 + itops->add_last_branch; 1083 1084 if (!ison) 1084 1085 return true; 1085 1086 pr_err("Unsupported --itrace options specified\n");