Skip to content

Commit 3e71fc0

Browse files
Jin Yaoacmel
authored andcommitted
perf annotate: Create hotkey 'c' to show min/max cycles
In the 'perf annotate' view, a new hotkey 'c' is created for showing the min/max cycles. For example, when press 'c', the annotate view is: Percent│ IPC Cycle(min/max) │ │ │ Disassembly of section .text: │ │ 000000000003aab0 <random@@GLIBC_2.2.5>: 8.22 │3.92 sub $0x18,%rsp │3.92 mov $0x1,%esi │3.92 xor %eax,%eax │3.92 cmpl $0x0,argp_program_version_hook@@g │3.92 1(2/1) ↓ je 20 │ lock cmpxchg %esi,__abort_msg@@GLIBC_P │ ↓ jne 29 │ ↓ jmp 43 │1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+ 8.93 │1.10 1(5/1) ↓ je 43 When press 'c' again, the annotate view is switched back: Percent│ IPC Cycle │ │ │ Disassembly of section .text: │ │ 000000000003aab0 <random@@GLIBC_2.2.5>: 8.22 │3.92 sub $0x18,%rsp │3.92 mov $0x1,%esi │3.92 xor %eax,%eax │3.92 cmpl $0x0,argp_program_version_hook@@GLIBC_2.2.5+0x │3.92 1 ↓ je 20 │ lock cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0 │ ↓ jne 29 │ ↓ jmp 43 │1.10 20: cmpxchg %esi,__abort_msg@@GLIBC_PRIVATE+0x8a0 8.93 │1.10 1 ↓ je 43 Signed-off-by: Jin Yao <[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] [ Rename all maxmin to minmax ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 48659eb commit 3e71fc0

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

tools/perf/ui/browsers/annotate.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
695695
"O Bump offset level (jump targets -> +call -> all -> cycle thru)\n"
696696
"s Toggle source code view\n"
697697
"t Circulate percent, total period, samples view\n"
698+
"c Show min/max cycle\n"
698699
"/ Search string\n"
699700
"k Toggle line numbers\n"
700701
"P Print to [symbol_name].annotation file.\n"
@@ -791,6 +792,13 @@ static int annotate_browser__run(struct annotate_browser *browser,
791792
notes->options->show_total_period = true;
792793
annotation__update_column_widths(notes);
793794
continue;
795+
case 'c':
796+
if (notes->options->show_minmax_cycle)
797+
notes->options->show_minmax_cycle = false;
798+
else
799+
notes->options->show_minmax_cycle = true;
800+
annotation__update_column_widths(notes);
801+
continue;
794802
case K_LEFT:
795803
case K_ESC:
796804
case 'q':

tools/perf/util/annotate.c

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,13 +2498,38 @@ static void __annotation_line__write(struct annotation_line *al, struct annotati
24982498
else
24992499
obj__printf(obj, "%*s ", ANNOTATION__IPC_WIDTH - 1, "IPC");
25002500

2501-
if (al->cycles)
2502-
obj__printf(obj, "%*" PRIu64 " ",
2501+
if (!notes->options->show_minmax_cycle) {
2502+
if (al->cycles)
2503+
obj__printf(obj, "%*" PRIu64 " ",
25032504
ANNOTATION__CYCLES_WIDTH - 1, al->cycles);
2504-
else if (!show_title)
2505-
obj__printf(obj, "%*s", ANNOTATION__CYCLES_WIDTH, " ");
2506-
else
2507-
obj__printf(obj, "%*s ", ANNOTATION__CYCLES_WIDTH - 1, "Cycle");
2505+
else if (!show_title)
2506+
obj__printf(obj, "%*s",
2507+
ANNOTATION__CYCLES_WIDTH, " ");
2508+
else
2509+
obj__printf(obj, "%*s ",
2510+
ANNOTATION__CYCLES_WIDTH - 1,
2511+
"Cycle");
2512+
} else {
2513+
if (al->cycles) {
2514+
char str[32];
2515+
2516+
scnprintf(str, sizeof(str),
2517+
"%" PRIu64 "(%" PRIu64 "/%" PRIu64 ")",
2518+
al->cycles, al->cycles_min,
2519+
al->cycles_max);
2520+
2521+
obj__printf(obj, "%*s ",
2522+
ANNOTATION__MINMAX_CYCLES_WIDTH - 1,
2523+
str);
2524+
} else if (!show_title)
2525+
obj__printf(obj, "%*s",
2526+
ANNOTATION__MINMAX_CYCLES_WIDTH,
2527+
" ");
2528+
else
2529+
obj__printf(obj, "%*s ",
2530+
ANNOTATION__MINMAX_CYCLES_WIDTH - 1,
2531+
"Cycle(min/max)");
2532+
}
25082533
}
25092534

25102535
obj__printf(obj, " ");

tools/perf/util/annotate.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);
6161

6262
#define ANNOTATION__IPC_WIDTH 6
6363
#define ANNOTATION__CYCLES_WIDTH 6
64+
#define ANNOTATION__MINMAX_CYCLES_WIDTH 19
6465

6566
struct annotation_options {
6667
bool hide_src_code,
@@ -69,7 +70,8 @@ struct annotation_options {
6970
show_linenr,
7071
show_nr_jumps,
7172
show_nr_samples,
72-
show_total_period;
73+
show_total_period,
74+
show_minmax_cycle;
7375
u8 offset_level;
7476
};
7577

@@ -243,6 +245,9 @@ struct annotation {
243245

244246
static inline int annotation__cycles_width(struct annotation *notes)
245247
{
248+
if (notes->have_cycles && notes->options->show_minmax_cycle)
249+
return ANNOTATION__IPC_WIDTH + ANNOTATION__MINMAX_CYCLES_WIDTH;
250+
246251
return notes->have_cycles ? ANNOTATION__IPC_WIDTH + ANNOTATION__CYCLES_WIDTH : 0;
247252
}
248253

0 commit comments

Comments
 (0)