Skip to content

Commit 48659eb

Browse files
Jin Yaoacmel
authored andcommitted
perf annotate: Record the min/max cycles
Currently perf has a feature to account cycles for LBRs For example, on skylake: perf record -b ... perf report or perf annotate And then browsing the annotate browser gives average cycle counts for program blocks. For some analysis it would be useful if we could know not only the average cycles but also the min and max cycles. This patch records the min and max cycles. Signed-off-by: Jin Yao <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ Switch from max/min to min/max ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 7903a70 commit 48659eb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tools/perf/util/annotate.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,15 @@ static int __symbol__account_cycles(struct annotation *notes,
760760
ch[offset].num_aggr++;
761761
ch[offset].cycles_aggr += cycles;
762762

763+
if (cycles > ch[offset].cycles_max)
764+
ch[offset].cycles_max = cycles;
765+
766+
if (ch[offset].cycles_min) {
767+
if (cycles && cycles < ch[offset].cycles_min)
768+
ch[offset].cycles_min = cycles;
769+
} else
770+
ch[offset].cycles_min = cycles;
771+
763772
if (!have_start && ch[offset].have_start)
764773
return 0;
765774
if (ch[offset].num) {
@@ -953,8 +962,11 @@ void annotation__compute_ipc(struct annotation *notes, size_t size)
953962
if (ch->have_start)
954963
annotation__count_and_fill(notes, ch->start, offset, ch);
955964
al = notes->offsets[offset];
956-
if (al && ch->num_aggr)
965+
if (al && ch->num_aggr) {
957966
al->cycles = ch->cycles_aggr / ch->num_aggr;
967+
al->cycles_max = ch->cycles_max;
968+
al->cycles_min = ch->cycles_min;
969+
}
958970
notes->have_cycles = true;
959971
}
960972
}

tools/perf/util/annotate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ struct annotation_line {
105105
int jump_sources;
106106
float ipc;
107107
u64 cycles;
108+
u64 cycles_max;
109+
u64 cycles_min;
108110
size_t privsize;
109111
char *path;
110112
u32 idx;
@@ -186,6 +188,8 @@ struct cyc_hist {
186188
u64 start;
187189
u64 cycles;
188190
u64 cycles_aggr;
191+
u64 cycles_max;
192+
u64 cycles_min;
189193
u32 num;
190194
u32 num_aggr;
191195
u8 have_start;

0 commit comments

Comments
 (0)