* [PATCH 1/2] perf script: Add summary to brstackinsn / brstackdisasm
2024-08-02 21:14 Minor improvements for brstackisn Andi Kleen
@ 2024-08-02 21:14 ` Andi Kleen
2024-08-02 21:14 ` [PATCH 2/2] perf report: Handle non capstone case for calling perf script Andi Kleen
1 sibling, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2024-08-02 21:14 UTC (permalink / raw)
To: linux-perf-users; +Cc: Andi Kleen
Print the total average IPC and total instructions for the last LBR entry.
This can be useful to quickly estimate if a sample shows problematic
code or not.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/builtin-script.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index c16224b1fef3..d8646366ac74 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1195,7 +1195,8 @@ 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 *total_cycles,
struct perf_event_attr *attr,
- struct thread *thread)
+ struct thread *thread,
+ int total_insn, bool end)
{
int ilen = 0;
int printed = fprintf(fp, "\t%016" PRIx64 "\t", ip);
@@ -1227,6 +1228,11 @@ static int ip__fprintf_jump(uint64_t ip, struct branch_entry *en,
if (insn)
printed += fprintf(fp, " %.2f IPC", (float)insn / en->flags.cycles);
}
+ if (end) {
+ printed += fprintf(fp, " %.2f total-IPC %d total-insns",
+ (float)total_insn / *total_cycles,
+ total_insn);
+ }
return printed + fprintf(fp, "\n");
}
@@ -1285,6 +1291,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
unsigned off;
struct symbol *lastsym = NULL;
int total_cycles = 0;
+ int total_insn = 0;
if (!(br && br->nr))
return 0;
@@ -1307,7 +1314,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
x.cpumode, x.cpu, &lastsym, attr, fp);
printed += ip__fprintf_jump(entries[nr - 1].from, &entries[nr - 1],
&x, buffer, len, 0, fp, &total_cycles,
- attr, thread);
+ attr, thread, 0, false);
if (PRINT_FIELD(SRCCODE))
printed += print_srccode(thread, x.cpumode, entries[nr - 1].from);
}
@@ -1338,7 +1345,7 @@ 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, &entries[i], &x, buffer + off, len - off, ++insn, fp,
- &total_cycles, attr, thread);
+ &total_cycles, attr, thread, total_insn, i == 0);
if (PRINT_FIELD(SRCCODE))
printed += print_srccode(thread, x.cpumode, ip);
break;
@@ -1346,6 +1353,7 @@ static int perf_sample__fprintf_brstackinsn(struct perf_sample *sample,
ilen = 0;
printed += fprintf(fp, "\t%016" PRIx64 "\t", ip);
printed += any_dump_insn(attr, &x, ip, buffer + off, len - off, &ilen, fp);
+ total_insn++;
if (PRINT_FIELD(BRSTACKINSNLEN))
printed += fprintf(fp, "\tilen: %d", ilen);
printed += fprintf(fp, "\n");
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread