From: kan.liang@linux.intel.com
To: acme@kernel.org, namhyung@kernel.org, irogers@google.com,
peterz@infradead.org, mingo@kernel.org,
linux-kernel@vger.kernel.org
Cc: adrian.hunter@intel.com, ak@linux.intel.com, eranian@google.com,
Kan Liang <kan.liang@linux.intel.com>
Subject: [PATCH 1/9] perf report: Fix --total-cycles --stdio output error
Date: Wed, 3 Jul 2024 13:03:48 -0700 [thread overview]
Message-ID: <20240703200356.852727-2-kan.liang@linux.intel.com> (raw)
In-Reply-To: <20240703200356.852727-1-kan.liang@linux.intel.com>
From: Kan Liang <kan.liang@linux.intel.com>
The --total-cycles may output wrong information with the --stdio.
For example,
perf record -e "{cycles,instructions}",cache-misses -b sleep 1
perf report --total-cycles --stdio
The total cycles output of {cycles,instructions} and cache-misses are
almost the same.
# Samples: 938 of events 'anon group { cycles, instructions }'
# Event count (approx.): 938
#
# Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles
# ............... .............. ........... ..........
..................................................>
#
11.19% 2.6K 0.10% 21
[perf_iterate_ctx+48 -> >
5.79% 1.4K 0.45% 97
[__intel_pmu_enable_all.constprop.0+80 -> __intel_>
5.11% 1.2K 0.33% 71
[native_write_msr+0 ->>
# Samples: 293 of event 'cache-misses'
# Event count (approx.): 293
#
# Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles
[>
# ............... .............. ........... ..........
..................................................>
#
11.19% 2.6K 0.13% 21
[perf_iterate_ctx+48 -> >
5.79% 1.4K 0.59% 97
[__intel_pmu_enable_all.constprop.0+80 -> __intel_>
5.11% 1.2K 0.43% 71
[native_write_msr+0 ->>
With the symbol_conf.event_group, the perf report should only report the
block information of the leader event in a group.
However, the current implementation retrieves the next event's block
information, rather than the next group leader's block information.
Make sure the index is updated even if the event is skipped.
With the patch,
# Samples: 293 of event 'cache-misses'
# Event count (approx.): 293
#
# Sampled Cycles% Sampled Cycles Avg Cycles% Avg Cycles
[>
# ............... .............. ........... ..........
..................................................>
#
37.98% 9.0K 4.05% 299
[perf_event_addr_filters_exec+0 -> perf_event_a>
11.19% 2.6K 0.28% 21
[perf_iterate_ctx+48 -> >
5.79% 1.4K 1.32% 97
[__intel_pmu_enable_all.constprop.0+80 -> __intel_>
Fixes: 6f7164fa231a ("perf report: Sort by sampled cycles percent per block for stdio")
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
tools/perf/builtin-report.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 9718770facb5..b9f22c5321da 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -565,6 +565,7 @@ static int evlist__tty_browse_hists(struct evlist *evlist, struct report *rep, c
struct hists *hists = evsel__hists(pos);
const char *evname = evsel__name(pos);
+ i++;
if (symbol_conf.event_group && !evsel__is_group_leader(pos))
continue;
@@ -574,7 +575,7 @@ static int evlist__tty_browse_hists(struct evlist *evlist, struct report *rep, c
hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
if (rep->total_cycles_mode) {
- report__browse_block_hists(&rep->block_reports[i++].hist,
+ report__browse_block_hists(&rep->block_reports[i - 1].hist,
rep->min_percent, pos, NULL);
continue;
}
--
2.38.1
next prev parent reply other threads:[~2024-07-03 20:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 20:03 [PATCH 0/9] Support branch counters in block annotation kan.liang
2024-07-03 20:03 ` kan.liang [this message]
2024-08-02 20:25 ` [PATCH 1/9] perf report: Fix --total-cycles --stdio output error Namhyung Kim
2024-07-03 20:03 ` [PATCH 2/9] perf report: Remove the first overflow check for branch counters kan.liang
2024-08-02 20:26 ` Namhyung Kim
2024-07-03 20:03 ` [PATCH 3/9] perf evlist: Save branch counters information kan.liang
2024-07-03 20:03 ` [PATCH 4/9] perf annotate: Save branch counters for each block kan.liang
2024-07-03 20:03 ` [PATCH 5/9] perf evsel: Assign abbr name for the branch counter events kan.liang
2024-08-03 0:14 ` Namhyung Kim
2024-08-06 14:11 ` Liang, Kan
2024-07-03 20:03 ` [PATCH 6/9] perf report: Display the branch counter histogram kan.liang
2024-08-03 0:18 ` Namhyung Kim
2024-08-06 14:39 ` Liang, Kan
2024-08-06 23:29 ` Namhyung Kim
2024-08-07 3:22 ` Andi Kleen
2024-08-07 11:57 ` Liang, Kan
2024-07-03 20:03 ` [PATCH 7/9] perf annotate: " kan.liang
2024-08-02 21:09 ` Andi Kleen
2024-08-06 14:42 ` Liang, Kan
2024-08-06 21:37 ` Liang, Kan
2024-08-06 23:02 ` Andi Kleen
2024-07-03 20:03 ` [PATCH 8/9] perf script: Add branch counters kan.liang
2024-07-03 20:03 ` [PATCH 9/9] perf test: Add new test cases for the branch counter feature kan.liang
2024-07-31 15:05 ` [PATCH 0/9] Support branch counters in block annotation Arnaldo Carvalho de Melo
2024-07-31 15:31 ` Liang, Kan
2024-07-31 17:00 ` Namhyung Kim
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=20240703200356.852727-2-kan.liang@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--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