From: Andi Kleen <andi@firstfloor.org>
To: acme@kernel.org
Cc: jolsa@kernel.org, adrian.hunter@intel.com,
linux-kernel@vger.kernel.org, kim.phillips@arm.com,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v5 9/9] perf, tools, script: Support total cycles count
Date: Tue, 18 Sep 2018 05:32:14 -0700 [thread overview]
Message-ID: <20180918123214.26728-10-andi@firstfloor.org> (raw)
In-Reply-To: <20180918123214.26728-1-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
For perf script brstackinsn also print a running cycles count.
This makes it easier to calculate cycle deltas for code sections
measured with LBRs.
% perf record -b -a sleep 1
% perf script -F +brstackinsn
...
_dl_sysdep_start+330:
00007eff9f20583a insn: 75 c4 # PRED 24 cycles [24]
00007eff9f205800 insn: 48 83 e8 03
00007eff9f205804 insn: 48 83 f8 1e
00007eff9f205808 insn: 77 26
00007eff9f20580a insn: 48 63 04 81
00007eff9f20580e insn: 48 01 c8
00007eff9f205811 insn: ff e0 # MISPRED 31 cycles [7] 0.71 IPC
00007eff9f2059c0 insn: 44 8b 62 08
00007eff9f2059c4 insn: e9 67 fe ff ff # PRED 55 cycles [24] 0.04 IPC
00007eff9f205830 insn: 48 83 c2 10
00007eff9f205834 insn: 48 8b 02
00007eff9f205837 insn: 48 85 c0
00007eff9f20583a insn: 75 c4 # PRED 68 cycles [13] 0.23 IPC
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/builtin-script.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3b73c3226141..84895c861b84 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -913,7 +913,7 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en,
struct perf_insn *x, u8 *inbuf, int len,
- int insn, FILE *fp)
+ int insn, FILE *fp, int *total_cycles)
{
int printed = fprintf(fp, "\t%016" PRIx64 "\t%-30s\t#%s%s%s%s", ip,
dump_insn(x, ip, inbuf, len, NULL),
@@ -922,7 +922,8 @@ static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en,
en->flags.in_tx ? " INTX" : "",
en->flags.abort ? " ABORT" : "");
if (en->flags.cycles) {
- printed += fprintf(fp, " %d cycles", en->flags.cycles);
+ *total_cycles += en->flags.cycles;
+ printed += fprintf(fp, " %d cycles [%d]", *total_cycles, en->flags.cycles);
if (insn)
printed += fprintf(fp, " %.2f IPC", (float)insn / en->flags.cycles);
}
@@ -979,6 +980,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
u8 buffer[MAXBB];
unsigned off;
struct symbol *lastsym = NULL;
+ int total_cycles = 0;
if (!(br && br->nr))
return 0;
@@ -999,7 +1001,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
printed += ip__fprintf_sym(br->entries[nr - 1].from, thread,
x.cpumode, x.cpu, &lastsym, attr, fp);
printed += ip__fprintf_jump(br->entries[nr - 1].from, &br->entries[nr - 1],
- &x, buffer, len, 0, fp);
+ &x, buffer, len, 0, fp, &total_cycles);
}
/* Print all blocks */
@@ -1027,7 +1029,9 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
printed += ip__fprintf_sym(ip, thread, x.cpumode, x.cpu, &lastsym, attr, fp);
if (ip == end) {
- printed += ip__fprintf_jump(ip, &br->entries[i], &x, buffer + off, len - off, insn, fp);
+ printed += ip__fprintf_jump(ip, &br->entries[i],
+ &x, buffer + off, len - off,
+ insn, fp, &total_cycles);
break;
} else {
printed += fprintf(fp, "\t%016" PRIx64 "\t%s\n", ip,
--
2.17.1
next prev parent reply other threads:[~2018-09-18 12:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 12:32 Make perf script easier to use for itrace Andi Kleen
2018-09-18 12:32 ` [PATCH v5 1/9] perf tools: Report itrace options in help Andi Kleen
2018-09-19 18:13 ` Arnaldo Carvalho de Melo
2018-09-18 12:32 ` [PATCH v5 2/9] tools, pager: Support overwriting the pager Andi Kleen
2018-09-19 18:17 ` Arnaldo Carvalho de Melo
2018-09-26 8:44 ` [tip:perf/core] tools lib subcmd: " tip-bot for Andi Kleen
2018-09-18 12:32 ` [PATCH v5 3/9] tools, perf, script: Add --insn-trace for instruction decoding Andi Kleen
2018-09-18 12:32 ` [PATCH v5 4/9] perf, tools, script: Allow sym and dso without ip, addr Andi Kleen
2018-09-19 18:24 ` Arnaldo Carvalho de Melo
2018-09-26 8:44 ` [tip:perf/core] perf " tip-bot for Andi Kleen
2018-09-18 12:32 ` [PATCH v5 5/9] perf, tools, script: Print DSO for callindent Andi Kleen
2018-09-19 18:26 ` Arnaldo Carvalho de Melo
2018-09-26 8:45 ` [tip:perf/core] perf " tip-bot for Andi Kleen
2018-09-18 12:32 ` [PATCH v5 6/9] perf, tools, script: Make itrace script default to all calls Andi Kleen
2018-09-18 13:24 ` Adrian Hunter
2018-09-19 18:28 ` Arnaldo Carvalho de Melo
2018-09-18 12:32 ` [PATCH v5 7/9] tools, perf, script: Add --call-trace and --call-ret-trace Andi Kleen
2018-09-18 12:32 ` [PATCH v5 8/9] tools, perf, script: Implement --graph-function Andi Kleen
2018-09-18 12:32 ` Andi Kleen [this message]
2018-09-19 18:31 ` [PATCH v5 9/9] perf, tools, script: Support total cycles count Arnaldo Carvalho de Melo
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=20180918123214.26728-10-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kim.phillips@arm.com \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome