* [PATCH 1/2] perf script: Add missed "+" if br_cntr reaches upper limit
@ 2026-04-10 19:39 Thomas Falcon
2026-04-10 19:40 ` [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode Thomas Falcon
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Falcon @ 2026-04-10 19:39 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>
Add missed "+" if br_cntr reaches upper limit.
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.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 c8ac9f01a36b..f865c8b2f95f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1287,8 +1287,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 (num == mask)
+ printed += fprintf(fp, "+");
+ } else {
+ printed += fprintf(fp, "%s %d%s", pos->name,
+ num, num == mask ? "+ " : " ");
+ }
}
if (numprinted == 0 && !verbose)
printed += fprintf(fp, "-");
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode
2026-04-10 19:39 [PATCH 1/2] perf script: Add missed "+" if br_cntr reaches upper limit Thomas Falcon
@ 2026-04-10 19:40 ` Thomas Falcon
2026-04-10 20:01 ` sashiko-bot
2026-04-10 20:19 ` [PATCH v2 " Thomas Falcon
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Falcon @ 2026-04-10 19:40 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.
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
---
tools/perf/builtin-annotate.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 5e57b78548f4..7fe23b05306f 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -563,6 +563,9 @@ static int __cmd_annotate(struct perf_annotate *ann)
if (ret)
goto out;
+ 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);
@@ -928,8 +931,6 @@ int cmd_annotate(int argc, const char **argv)
*/
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)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode
2026-04-10 19:40 ` [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode Thomas Falcon
@ 2026-04-10 20:01 ` sashiko-bot
2026-04-10 20:05 ` Falcon, Thomas
2026-04-10 20:19 ` [PATCH v2 " Thomas Falcon
1 sibling, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-04-10 20:01 UTC (permalink / raw)
To: Thomas Falcon; +Cc: linux-perf-users
Sashiko AI review found 1 potential issue(s):
- [Medium] The branch counter column is now enabled in standard stdio mode where it cannot be populated, resulting in a useless empty column in the output.
--
commit afd424a34255fcd5587246caa606560bc9b916c8
Author: Thomas Falcon <thomas.falcon@intel.com>
perf/annotate: Fix missing branch counter column in TUI mode
This commit moves the check for enabling the branch counter column into
__cmd_annotate() so it occurs after events have been processed and the
counter is updated.
> diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
> index 5e57b78548f42..7fe23b05306f8 100644
> --- a/tools/perf/builtin-annotate.c
> +++ b/tools/perf/builtin-annotate.c
> @@ -563,6 +563,9 @@ static int __cmd_annotate(struct perf_annotate *ann)
> if (ret)
> goto out;
>
> + if (session->evlist->nr_br_cntr > 0)
> + annotate_opts.show_br_cntr = true;
> +
Will this cause an empty branch counter column to be displayed in standard
stdio mode?
The original code restricted this check to TUI and stdio2 modes where
use_browser == 1 or annotate.use_stdio2 is true. By moving the assignment
here, it becomes unconditional.
In standard stdio mode, process_branch_callback() is skipped when adding
samples, so branch stack data is not aggregated into the annotation notes.
This leaves the counter data at 0 for all instructions. Could this result
in the output rendering the column title but printing only empty spaces for
all the rows?
[ ... ]
> @@ -928,8 +931,6 @@ int cmd_annotate(int argc, const char **argv)
> */
> 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)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260410194000.219846-1-thomas.falcon@intel.com?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode
2026-04-10 20:01 ` sashiko-bot
@ 2026-04-10 20:05 ` Falcon, Thomas
0 siblings, 0 replies; 5+ messages in thread
From: Falcon, Thomas @ 2026-04-10 20:05 UTC (permalink / raw)
To: sashiko@lists.linux.dev; +Cc: linux-perf-users@vger.kernel.org
On Fri, 2026-04-10 at 20:01 +0000, sashiko-bot@kernel.org wrote:
> Sashiko AI review found 1 potential issue(s):
> - [Medium] The branch counter column is now enabled in standard stdio
> mode where it cannot be populated, resulting in a useless empty
> column in the output.
> --
>
> commit afd424a34255fcd5587246caa606560bc9b916c8
> Author: Thomas Falcon <thomas.falcon@intel.com>
>
> perf/annotate: Fix missing branch counter column in TUI mode
>
> This commit moves the check for enabling the branch counter column
> into
> __cmd_annotate() so it occurs after events have been processed and
> the
> counter is updated.
>
> > diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-
> > annotate.c
> > index 5e57b78548f42..7fe23b05306f8 100644
> > --- a/tools/perf/builtin-annotate.c
> > +++ b/tools/perf/builtin-annotate.c
> > @@ -563,6 +563,9 @@ static int __cmd_annotate(struct perf_annotate
> > *ann)
> > if (ret)
> > goto out;
> >
> > + if (session->evlist->nr_br_cntr > 0)
> > + annotate_opts.show_br_cntr = true;
> > +
>
> Will this cause an empty branch counter column to be displayed in
> standard
> stdio mode?
Oops, this was an older version, I'll resend with an updated one.
Thanks,
Tom
>
> The original code restricted this check to TUI and stdio2 modes where
> use_browser == 1 or annotate.use_stdio2 is true. By moving the
> assignment
> here, it becomes unconditional.
>
> In standard stdio mode, process_branch_callback() is skipped when
> adding
> samples, so branch stack data is not aggregated into the annotation
> notes.
> This leaves the counter data at 0 for all instructions. Could this
> result
> in the output rendering the column title but printing only empty
> spaces for
> all the rows?
>
> [ ... ]
>
> > @@ -928,8 +931,6 @@ int cmd_annotate(int argc, const char **argv)
> > */
> > 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)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] perf/annotate: Fix missing branch counter column in TUI mode
2026-04-10 19:40 ` [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode Thomas Falcon
2026-04-10 20:01 ` sashiko-bot
@ 2026-04-10 20:19 ` Thomas Falcon
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Falcon @ 2026-04-10 20:19 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.
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
---
v2: Sent an older version by mistake, updated to the latest version.
---
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 5e57b78548f4..7bddbaee1cde 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -563,6 +563,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);
@@ -926,11 +930,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] 5+ messages in thread
end of thread, other threads:[~2026-04-10 20:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 19:39 [PATCH 1/2] perf script: Add missed "+" if br_cntr reaches upper limit Thomas Falcon
2026-04-10 19:40 ` [PATCH 2/2] perf/annotate: Fix missing branch counter column in TUI mode Thomas Falcon
2026-04-10 20:01 ` sashiko-bot
2026-04-10 20:05 ` Falcon, Thomas
2026-04-10 20:19 ` [PATCH v2 " Thomas Falcon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox