]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf annotate: Fix missing branch counter column in TUI mode
authorThomas Falcon <thomas.falcon@intel.com>
Thu, 28 May 2026 15:36:37 +0000 (10:36 -0500)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 30 May 2026 00:23:09 +0000 (21:23 -0300)
'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.

Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-annotate.c

index 719b36d4eed5bc40b4628185bf482396deebaf1c..5f450c8093c092109ee265f6b04a3c35ad0cfafc 100644 (file)
@@ -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);