]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf script: Fix brcntr output with --xed
authorAndi Kleen <andi@firstfloor.org>
Wed, 18 Feb 2026 01:40:56 +0000 (17:40 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 26 Feb 2026 01:58:00 +0000 (17:58 -0800)
commit0feca0b788567debbaec6a9a329f5bee1b15c705
tree42d20fdc332a846c393e8d2d13129b0eeeac8d7f
parentc5a244bf17caf2de22f9e100832b75f72b31d3e6
perf script: Fix brcntr output with --xed

brcntr in perf script brstack insn currently outputs

  $ perf record -j any,counter ...
  $ perf script -F +brcntr,+brstackinsn
  ...
              BC1s 3450809 5665912.127194:     100127
  cpu_core/cycles/:      7f0475d6cc89 handle_intel.constprop.0+0x2b
  (/usr/lib64/ld-linux-
  x86-64.so.2)
          intel_check_word.constprop.0+224:
          00007f0475d6ca7e        insn: 00 4b db                  br_cntr: # PRED 21 cycles [21]
  ...

This has two issues:
- The description says no event is a single dash, but that is not what is printed.
- The b in brcntr is ambigious with the hex numbers in insns, which
  breaks with --xed. It parses the b as another instruction byte and
merges the instruction with a missing b and no space:

  $ perf script -F +brstackinsn,+brcntr --xed
  ...
          00005618c6d683b5                        jnz 0x5618c6d683bdr_cntr:       # PRED 5 cycles [1396] 8.60 IPC

This patches fixes these two problems. It moves the brcntr output into
the "#" comment which also looks nicer and also fixes the no event case.

  $ perf script -F +brstackinsn,+brcntr --xed
  ...
          00005618c6d6624f                        jnz 0x5618c6d65fb7 # br_cntr: -  MISPRED 1 cycles [1398] 3.00 IPC

Since the old broken format has shipped for a few releases there is a
risk of breaking some existing parser, but since this is a obscure
feature I hope they're not too common and can adapt.

Signed-off-by: Andi Kleen <andi@firstfloor.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/builtin-script.c