From: James Clark <james.clark@linaro.org>
To: Gu Bin <gubin@cmss.chinamobile.com>
Cc: peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org,
mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: Re: [PATCH] perf hist: Fix branch_info index for sample weight
Date: Wed, 4 Nov 2026 09:22:42 +0000 [thread overview]
Message-ID: <0f57d95c-fb84-4e70-8c86-e5314c0ca8f2@linaro.org> (raw)
In-Reply-To: <20261104090229.1870-1-gubin@cmss.chinamobile.com>
On 04/11/2026 09:02, Gu Bin wrote:
> iter_add_next_branch_entry() is called once per branch and uses &bi[i]
> for the hist entry, but reads the weight from bi->flags.cycles (i.e.
> bi[0]) for every branch, so every entry is weighted with the first
> branch's cycle count. This is incorrect when the branch stack contains
> more than one entry with different cycle counts, as the weight of each
> hist entry fails to reflect the cycles of its own branch.
>
> Use bi[i].flags.cycles, as the surrounding code already does.
>
> Fixes: 0e332f033a82 ("perf tools: Add support for cycles, weight branch_info field")
> Signed-off-by: Gu Bin <gubin@cmss.chinamobile.com>
> ---
> tools/perf/util/hist.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
> index e75a4fcce975..364754e9d12a 100644
> --- a/tools/perf/util/hist.c
> +++ b/tools/perf/util/hist.c
> @@ -1055,7 +1055,7 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a
> * and not events sampled. Thus we use a pseudo period of 1.
> */
> sample->period = 1;
> - sample->weight = bi->flags.cycles ? bi->flags.cycles : 1;
> + sample->weight = bi[i].flags.cycles ? bi[i].flags.cycles : 1;
>
> he = hists__add_entry(hists, al, iter->parent, &bi[i], NULL, NULL,
> sample, true);
Reviewed-by: James Clark <james.clark@linaro.org>
prev parent reply other threads:[~2026-11-04 9:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 9:02 Gu Bin
2026-11-04 9:22 ` James Clark [this message]
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=0f57d95c-fb84-4e70-8c86-e5314c0ca8f2@linaro.org \
--to=james.clark@linaro.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=gubin@cmss.chinamobile.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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
all inboxes | Powered by JetHome®