From: sashiko-bot@kernel.org
To: "Thomas Falcon" <thomas.falcon@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/2 v2] perf script: Fix missing '+' indicator when branch counter reaches upper limit
Date: Wed, 29 Apr 2026 19:58:37 +0000 [thread overview]
Message-ID: <20260429195839.29BF7C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260429152917.178803-2-thomas.falcon@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch incorrectly prints the saturation indicator '+' when branch counter width is 0.
--
commit 7ec212bf30c80539ef5e37c2e9ff148610e094d5
Author: Dapeng Mi <dapeng1.mi@linux.intel.com>
perf script: Fix missing '+' indicator when branch counter reaches upper limit
This commit restores the missing "+" suffix indicator in perf script which
represents that branch counter events may have been lost due to saturation.
> 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)
Could this incorrectly print the saturation indicator if the branch counter
width is 0?
Since mask is derived via (1L << width) - 1 earlier in the function:
perf_env__find_br_cntr_info(evsel__env(evsel), NULL, &width);
mask = (1L << width) - 1;
A width of 0 results in a mask of 0. In this scenario, num will also evaluate
to 0, making the condition num == mask evaluate to true.
Would it be better to verify that mask > 0 before checking for saturation?
> + printed += fprintf(fp, "+");
> + } else {
> + printed += fprintf(fp, "%s %d%s", pos->name,
> + num, num == mask ? "+ " : " ");
Is a similar check needed here to prevent the same false positive in
verbose mode?
> + }
> }
> if (numprinted == 0 && !verbose)
> printed += fprintf(fp, "-");
In non-verbose mode, a false positive on the mask check introduces a
regression where the output becomes +- since the numprinted == 0 condition
above will also append a "-", contradicting the intention that "-" means no
event occurred.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260429152917.178803-1-thomas.falcon@intel.com?part=1
next prev parent reply other threads:[~2026-04-29 19:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 15:29 [PATCH 0/2 v2] perf: Fix missing branch counter information in script and annotate Thomas Falcon
2026-04-29 15:29 ` [PATCH 1/2 v2] perf script: Fix missing '+' indicator when branch counter reaches upper limit Thomas Falcon
2026-04-29 19:58 ` sashiko-bot [this message]
2026-04-30 0:37 ` Mi, Dapeng
2026-04-29 15:29 ` [PATCH 2/2 v2] perf annotate: Fix missing branch counter column in TUI mode Thomas Falcon
2026-04-30 0:38 ` Mi, Dapeng
2026-05-11 18:05 ` [PATCH 0/2 v2] perf: Fix missing branch counter information in script and annotate Falcon, Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260429195839.29BF7C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=thomas.falcon@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox