Re: [PATCH 1/2 v2] perf script: Fix missing '+' indicator when branch counter reaches upper limit

From: Mi, Dapeng

Date: Wed Apr 29 2026 - 20:37:23 EST



On 4/29/2026 11:29 PM, Thomas Falcon wrote:
> From: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
>
> 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]
> ...
>
> Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
> Signed-off-by: Thomas Falcon <thomas.falcon@xxxxxxxxx>
> ---
> 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, "-");

Reviewed-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>