diff options
author | Mike Galbraith <efault@gmx.de> | 2009-07-24 04:09:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-09 06:54:30 -0400 |
commit | 46ab976443c6c566c8fe6fc72a6733a55ba9fbea (patch) | |
tree | 53db4a44087cddf14b0b8cd8bc8911d4998fd2ff /tools/perf | |
parent | 923c42c19944da214d697e312a040384a0e33e78 (diff) |
perf_counter tools: Allow perf top top users to switch between weighted and individual counter display
Add [w]eighted hotkey. Pressing [w] toggles between displaying
weighted total of all counters, and the counter selected via
[E]vent select key.
------------------------------------------------------------------------------
PerfTop: 90395 irqs/sec kernel:16.1% [cache-misses/cache-references/instructions], (all, 4 CPUs)
------------------------------------------------------------------------------
weight samples pcnt RIP kernel function
______ _______ _____ ________________ _______________
1275408.6 10881 - 5.3% - ffffffff81146f70 : copy_page_c
553683.4 43569 - 21.3% - ffffffff81146f20 : clear_page_c
74075.0 6768 - 3.3% - ffffffff81147190 : copy_user_generic_string
40602.9 7538 - 3.7% - ffffffff81284ba2 : _spin_lock
26882.1 965 - 0.5% - ffffffff8109d280 : file_ra_state_init
[w]
------------------------------------------------------------------------------
PerfTop: 91221 irqs/sec kernel:14.5% [10000Hz cache-misses], (all, 4 CPUs)
------------------------------------------------------------------------------
weight samples pcnt RIP kernel function
______ _______ _____ ________________ _______________
47320.00 - 22.3% - ffffffff81146f20 : clear_page_c
14261.00 - 6.7% - ffffffff810992f5 : __rmqueue
11046.00 - 5.2% - ffffffff81146f70 : copy_page_c
7842.00 - 3.7% - ffffffff81284ba2 : _spin_lock
7234.00 - 3.4% - ffffffff810aa1d6 : unmap_vmas
Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-top.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index d58701346b1e..4eef3465e837 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -90,6 +90,7 @@ static char *sym_filter = NULL; | |||
90 | struct sym_entry *sym_filter_entry = NULL; | 90 | struct sym_entry *sym_filter_entry = NULL; |
91 | static int sym_pcnt_filter = 5; | 91 | static int sym_pcnt_filter = 5; |
92 | static int sym_counter = 0; | 92 | static int sym_counter = 0; |
93 | static int display_weighted = -1; | ||
93 | 94 | ||
94 | /* | 95 | /* |
95 | * Symbols | 96 | * Symbols |
@@ -354,6 +355,9 @@ static double sym_weight(const struct sym_entry *sym) | |||
354 | double weight = sym->snap_count; | 355 | double weight = sym->snap_count; |
355 | int counter; | 356 | int counter; |
356 | 357 | ||
358 | if (!display_weighted) | ||
359 | return weight; | ||
360 | |||
357 | for (counter = 1; counter < nr_counters-1; counter++) | 361 | for (counter = 1; counter < nr_counters-1; counter++) |
358 | weight *= sym->count[counter]; | 362 | weight *= sym->count[counter]; |
359 | 363 | ||
@@ -401,7 +405,7 @@ static void rb_insert_active_sym(struct rb_root *tree, struct sym_entry *se) | |||
401 | static void print_sym_table(void) | 405 | static void print_sym_table(void) |
402 | { | 406 | { |
403 | int printed = 0, j; | 407 | int printed = 0, j; |
404 | int counter; | 408 | int counter, snap = !display_weighted ? sym_counter : 0; |
405 | float samples_per_sec = samples/delay_secs; | 409 | float samples_per_sec = samples/delay_secs; |
406 | float ksamples_per_sec = (samples-userspace_samples)/delay_secs; | 410 | float ksamples_per_sec = (samples-userspace_samples)/delay_secs; |
407 | float sum_ksamples = 0.0; | 411 | float sum_ksamples = 0.0; |
@@ -417,7 +421,7 @@ static void print_sym_table(void) | |||
417 | pthread_mutex_unlock(&active_symbols_lock); | 421 | pthread_mutex_unlock(&active_symbols_lock); |
418 | 422 | ||
419 | list_for_each_entry_safe_from(syme, n, &active_symbols, node) { | 423 | list_for_each_entry_safe_from(syme, n, &active_symbols, node) { |
420 | syme->snap_count = syme->count[0]; | 424 | syme->snap_count = syme->count[snap]; |
421 | if (syme->snap_count != 0) { | 425 | if (syme->snap_count != 0) { |
422 | syme->weight = sym_weight(syme); | 426 | syme->weight = sym_weight(syme); |
423 | rb_insert_active_sym(&tmp, syme); | 427 | rb_insert_active_sym(&tmp, syme); |
@@ -437,7 +441,7 @@ static void print_sym_table(void) | |||
437 | samples_per_sec, | 441 | samples_per_sec, |
438 | 100.0 - (100.0*((samples_per_sec-ksamples_per_sec)/samples_per_sec))); | 442 | 100.0 - (100.0*((samples_per_sec-ksamples_per_sec)/samples_per_sec))); |
439 | 443 | ||
440 | if (nr_counters == 1) { | 444 | if (nr_counters == 1 || !display_weighted) { |
441 | printf("%Ld", (u64)attrs[0].sample_period); | 445 | printf("%Ld", (u64)attrs[0].sample_period); |
442 | if (freq) | 446 | if (freq) |
443 | printf("Hz "); | 447 | printf("Hz "); |
@@ -445,7 +449,9 @@ static void print_sym_table(void) | |||
445 | printf(" "); | 449 | printf(" "); |
446 | } | 450 | } |
447 | 451 | ||
448 | for (counter = 0; counter < nr_counters; counter++) { | 452 | if (!display_weighted) |
453 | printf("%s", event_name(sym_counter)); | ||
454 | else for (counter = 0; counter < nr_counters; counter++) { | ||
449 | if (counter) | 455 | if (counter) |
450 | printf("/"); | 456 | printf("/"); |
451 | 457 | ||
@@ -495,7 +501,7 @@ static void print_sym_table(void) | |||
495 | pcnt = 100.0 - (100.0 * ((sum_ksamples - syme->snap_count) / | 501 | pcnt = 100.0 - (100.0 * ((sum_ksamples - syme->snap_count) / |
496 | sum_ksamples)); | 502 | sum_ksamples)); |
497 | 503 | ||
498 | if (nr_counters == 1) | 504 | if (nr_counters == 1 || !display_weighted) |
499 | printf("%20.2f - ", syme->weight); | 505 | printf("%20.2f - ", syme->weight); |
500 | else | 506 | else |
501 | printf("%9.1f %10ld - ", syme->weight, syme->snap_count); | 507 | printf("%9.1f %10ld - ", syme->weight, syme->snap_count); |
@@ -594,13 +600,14 @@ static void print_known_keys(void) | |||
594 | fprintf(stdout, "\nknown keys:\n"); | 600 | fprintf(stdout, "\nknown keys:\n"); |
595 | fprintf(stdout, "\t[d] select display delay.\n"); | 601 | fprintf(stdout, "\t[d] select display delay.\n"); |
596 | fprintf(stdout, "\t[e] select display entries (lines).\n"); | 602 | fprintf(stdout, "\t[e] select display entries (lines).\n"); |
597 | fprintf(stdout, "\t[E] select annotation event counter.\n"); | 603 | fprintf(stdout, "\t[E] active event counter. \t(%s)\n", event_name(sym_counter)); |
598 | fprintf(stdout, "\t[f] select normal display count filter.\n"); | 604 | fprintf(stdout, "\t[f] select normal display count filter.\n"); |
599 | fprintf(stdout, "\t[F] select annotation display count filter (percentage).\n"); | 605 | fprintf(stdout, "\t[F] select annotation display count filter (percentage).\n"); |
600 | fprintf(stdout, "\t[qQ] quit.\n"); | 606 | fprintf(stdout, "\t[qQ] quit.\n"); |
601 | fprintf(stdout, "\t[s] select annotation symbol and start annotation.\n"); | 607 | fprintf(stdout, "\t[s] select annotation symbol and start annotation.\n"); |
602 | fprintf(stdout, "\t[S] stop annotation, revert to normal display.\n"); | 608 | fprintf(stdout, "\t[S] stop annotation, revert to normal display.\n"); |
603 | fprintf(stdout, "\t[z] toggle event count zeroing.\n"); | 609 | fprintf(stdout, "\t[w] toggle display weighted/count[E]r. \t(%d)\n", display_weighted ? 1 : 0); |
610 | fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", zero ? 1 : 0); | ||
604 | } | 611 | } |
605 | 612 | ||
606 | static void handle_keypress(int c) | 613 | static void handle_keypress(int c) |
@@ -656,6 +663,9 @@ repeat: | |||
656 | pthread_mutex_unlock(&syme->source_lock); | 663 | pthread_mutex_unlock(&syme->source_lock); |
657 | } | 664 | } |
658 | break; | 665 | break; |
666 | case 'w': | ||
667 | display_weighted = ~display_weighted; | ||
668 | break; | ||
659 | case 'z': | 669 | case 'z': |
660 | zero = ~zero; | 670 | zero = ~zero; |
661 | break; | 671 | break; |