2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/tools/perf/util/intel-pt-decoder
Andi Kleen bf0db8c759 perf script: Minimize "not reaching sample" for '-F +brstackinsn'
In some situations 'perf script -F +brstackinsn' sees a lot of "not
reaching sample" messages.

This happens when the last LBR block before the sample contains a branch
that is not in the LBR, and the instruction dumping stops.

  $ perf record -b  emacs -Q --batch '()'
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.396 MB perf.data (443 samples) ]
  $ perf script -F +brstackinsn
  ...
          00007f0ab2d171a4        insn: 41 0f 94 c0
          00007f0ab2d171a8        insn: 83 fa 01
          00007f0ab2d171ab        insn: 74 d3                     # PRED 6 cycles [313] 1.00 IPC
          00007f0ab2d17180        insn: 45 84 c0
          00007f0ab2d17183        insn: 74 28
          ... not reaching sample ...

  $ perf script -F +brstackinsn | grep -c reach
  136
  $

This is a problem for further analysis that wants to see the full code
upto the sample.

There are two common cases where the message is bogus:

- The LBR only logs taken branches, but the branch might be a
  conditional branch that is not taken (that is the most common case
  actually)

- The LBR sampling uses a filter ignoring some branches, but the perf
  script check checks for all branches.

This patch fixes these two conditions, by only checking for conditional
branches, as well as checking the perf_event_attr's branch filter
attributes.

For the test case above it fixes all the messages:

  $ ./perf script -F +brstackinsn | grep -c reach
  0

Note that there are still conditions when the message is hit --
sometimes there can be a unconditional branch that misses the LBR update
before the sample -- but they are much more rare now.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20240229161828.386397-1-ak@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-09-03 12:22:01 -03:00
..
Build perf util: Make util its own library 2024-06-26 11:07:42 -07:00
intel-pt-decoder.c perf intel-pt: Fix unassigned instruction op (discovered by MemorySanitizer) 2024-04-26 22:13:10 -03:00
intel-pt-decoder.h perf intel-pt: Add support for emulated ptwrite 2022-05-17 11:55:49 -03:00
intel-pt-insn-decoder.c perf script: Minimize "not reaching sample" for '-F +brstackinsn' 2024-09-03 12:22:01 -03:00
intel-pt-insn-decoder.h perf intel-pt: Add support for new branch instructions ERETS and ERETU 2023-03-20 19:25:40 -03:00
intel-pt-log.c perf intel-pt: Remove first line of log dumped on error 2022-10-04 08:55:21 -03:00
intel-pt-log.h perf intel-pt: Support itrace option flag d+e to log on error 2022-10-04 08:55:21 -03:00
intel-pt-pkt-decoder.c perf intel-pt: Prefer get_unaligned_le64 to memcpy_le64 2023-10-17 12:40:50 -07:00
intel-pt-pkt-decoder.h perf intel-pt: pkt-decoder: Add CFE and EVD packets 2022-02-15 17:05:44 -03:00