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

perf intel-pt: Fix missing 'instruction' events with 'q' option

FUP packets contain IP information, which makes them also an 'instruction'
event in 'hop' mode i.e. the itrace 'q' option. That wasn't happening, so
restructure the logic so that FUP events are added along with appropriate
'instruction' and 'branch' events.

Fixes: 7c1b16ba0e26e6 ("perf intel-pt: Add support for decoding FUP/TIP only")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org # v5.15+
Link: https://lore.kernel.org/r/20211210162303.2288710-7-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
a882cc94 a32e6c5d

+8 -3
+8 -3
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
··· 2683 2683 /* Hop mode: Ignore TNT, do not walk code, but get ip from FUPs and TIPs */ 2684 2684 static int intel_pt_hop_trace(struct intel_pt_decoder *decoder, bool *no_tip, int *err) 2685 2685 { 2686 + *err = 0; 2687 + 2686 2688 /* Leap from PSB to PSB, getting ip from FUP within PSB+ */ 2687 2689 if (decoder->leap && !decoder->in_psb && decoder->packet.type != INTEL_PT_PSB) { 2688 2690 *err = intel_pt_scan_for_psb(decoder); ··· 2725 2723 if (!decoder->packet.count) 2726 2724 return HOP_IGNORE; 2727 2725 intel_pt_set_ip(decoder); 2728 - if (intel_pt_fup_event(decoder)) 2729 - return HOP_RETURN; 2726 + if (decoder->set_fup_mwait || decoder->set_fup_pwre) 2727 + *no_tip = true; 2730 2728 if (!decoder->branch_enable || !decoder->pge) 2731 2729 *no_tip = true; 2732 2730 if (*no_tip) { 2733 2731 decoder->state.type = INTEL_PT_INSTRUCTION; 2734 2732 decoder->state.from_ip = decoder->ip; 2735 2733 decoder->state.to_ip = 0; 2734 + intel_pt_fup_event(decoder); 2736 2735 return HOP_RETURN; 2737 2736 } 2737 + intel_pt_fup_event(decoder); 2738 + decoder->state.type |= INTEL_PT_INSTRUCTION | INTEL_PT_BRANCH; 2738 2739 *err = intel_pt_walk_fup_tip(decoder); 2739 - if (!*err) 2740 + if (!*err && decoder->state.to_ip) 2740 2741 decoder->pkt_state = INTEL_PT_STATE_RESAMPLE; 2741 2742 return HOP_RETURN; 2742 2743