* [PATCH v3 1/2] perf script: Fix missing '+' indicator when branch counter reaches upper limit
2026-05-28 15:36 [PATCH v3 0/2] perf: Fix missing branch counter information in script and annotate Thomas Falcon
@ 2026-05-28 15:36 ` Thomas Falcon
2026-05-28 15:36 ` [PATCH v3 2/2] perf/annotate: Fix missing branch counter column in TUI mode Thomas Falcon
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Falcon @ 2026-05-28 15:36 UTC (permalink / raw)
To: linux-perf-users
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Dapeng Mi
From: Dapeng Mi <dapeng1.mi@linux.intel.com>
When displaying branch counter (br_cntr) information, a "+"
suffix represents that event occurrences may have been lost
due to branch counter saturation. However, this indicator was
missing in perf script. Add it back.
Before:
# Branch counter abbr list:
# cpu_core/event=0xc4,umask=0x20/ppp = A
# cpu_core/instructions/ = B
# cpu_core/MEM_INST_RETIRED.ALL_LOADS/ = C
# cpu_core/MEM_LOAD_RETIRED.L2_MISS/ = D
# '-' No event occurs
# '+' Event occurrences may be lost due to branch counter saturated
...
datasym+190:
00005567f9951676 jz 0x5567f995162dr_cntr: BBBC # PRED 1 cycles [1]
...
After:
...
datasym+190:
00005567f9951676 jz 0x5567f995162dr_cntr: BBB+C # PRED 1 cycles [1]
...
Acked-by: Ian Rogers <irogers@google.com>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
---
tools/perf/builtin-script.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c0918006e0ab..7d78adb7995a 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1288,8 +1288,12 @@ static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en,
if (!verbose) {
for (j = 0; j < num; j++)
printed += fprintf(fp, "%s", pos->abbr_name);
- } else
- printed += fprintf(fp, "%s %d ", pos->name, num);
+ if (mask && (num == mask))
+ printed += fprintf(fp, "+");
+ } else {
+ printed += fprintf(fp, "%s %d%s", pos->name,
+ num, mask && (num == mask) ? "+ " : " ");
+ }
}
if (numprinted == 0 && !verbose)
printed += fprintf(fp, "-");
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v3 2/2] perf/annotate: Fix missing branch counter column in TUI mode
2026-05-28 15:36 [PATCH v3 0/2] perf: Fix missing branch counter information in script and annotate Thomas Falcon
2026-05-28 15:36 ` [PATCH v3 1/2] perf script: Fix missing '+' indicator when branch counter reaches upper limit Thomas Falcon
@ 2026-05-28 15:36 ` Thomas Falcon
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Falcon @ 2026-05-28 15:36 UTC (permalink / raw)
To: linux-perf-users
Cc: linux-kernel, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
James Clark, Dapeng Mi
perf annotate checks that evlist->nr_br_cntr has been incremented
to determine whether to show branch counter information. However,
this data is not populated until after the check when events are
processed. Therefore, this counter will always be less than zero
and the Branch Count column is never shown. Do this check after
events have been processed and branch counter data is updated.
Acked-by: Ian Rogers <irogers@google.com>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
---
tools/perf/builtin-annotate.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 719b36d4eed5..5f450c8093c0 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -559,6 +559,10 @@ static int __cmd_annotate(struct perf_annotate *ann)
if (ret)
goto out;
+ if ((use_browser == 1 || ann->use_stdio2) && ann->has_br_stack)
+ if (session->evlist->nr_br_cntr > 0)
+ annotate_opts.show_br_cntr = true;
+
if (dump_trace) {
perf_session__fprintf_nr_events(session, stdout);
evlist__fprintf_nr_events(session->evlist, stdout);
@@ -922,11 +926,8 @@ int cmd_annotate(int argc, const char **argv)
* branch counters, if the corresponding branch info is available
* in the perf data in the TUI mode.
*/
- if ((use_browser == 1 || annotate.use_stdio2) && annotate.has_br_stack) {
+ if ((use_browser == 1 || annotate.use_stdio2) && annotate.has_br_stack)
sort__mode = SORT_MODE__BRANCH;
- if (annotate.session->evlist->nr_br_cntr > 0)
- annotate_opts.show_br_cntr = true;
- }
if (setup_sorting(/*evlist=*/NULL, perf_session__env(annotate.session)) < 0)
usage_with_options(annotate_usage, options);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread