aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 7de28ce9ca26..4002ccb36750 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -27,6 +27,8 @@
27#include "util/parse-options.h" 27#include "util/parse-options.h"
28#include "util/parse-events.h" 28#include "util/parse-events.h"
29 29
30#include "util/debug.h"
31
30#include <assert.h> 32#include <assert.h>
31#include <fcntl.h> 33#include <fcntl.h>
32 34
@@ -68,8 +70,6 @@ static int group = 0;
68static unsigned int page_size; 70static unsigned int page_size;
69static unsigned int mmap_pages = 16; 71static unsigned int mmap_pages = 16;
70static int freq = 0; 72static int freq = 0;
71static int verbose = 0;
72static char *vmlinux = NULL;
73 73
74static int delay_secs = 2; 74static int delay_secs = 2;
75static int zero; 75static int zero;
@@ -122,7 +122,8 @@ static void parse_source(struct sym_entry *syme)
122 struct module *module; 122 struct module *module;
123 struct section *section = NULL; 123 struct section *section = NULL;
124 FILE *file; 124 FILE *file;
125 char command[PATH_MAX*2], *path = vmlinux; 125 char command[PATH_MAX*2];
126 const char *path = vmlinux_name;
126 u64 start, end, len; 127 u64 start, end, len;
127 128
128 if (!syme) 129 if (!syme)
@@ -338,8 +339,6 @@ static void show_details(struct sym_entry *syme)
338 printf("%d lines not displayed, maybe increase display entries [e]\n", more); 339 printf("%d lines not displayed, maybe increase display entries [e]\n", more);
339} 340}
340 341
341struct dso *kernel_dso;
342
343/* 342/*
344 * Symbols will be added here in record_ip and will get out 343 * Symbols will be added here in record_ip and will get out
345 * after decayed. 344 * after decayed.
@@ -484,17 +483,24 @@ static void print_sym_table(void)
484 if (nr_counters == 1) 483 if (nr_counters == 1)
485 printf(" samples pcnt"); 484 printf(" samples pcnt");
486 else 485 else
487 printf(" weight samples pcnt"); 486 printf(" weight samples pcnt");
488 487
489 printf(" RIP kernel function\n" 488 if (verbose)
490 " ______ _______ _____ ________________ _______________\n\n" 489 printf(" RIP ");
491 ); 490 printf(" kernel function\n");
491 printf(" %s _______ _____",
492 nr_counters == 1 ? " " : "______");
493 if (verbose)
494 printf(" ________________");
495 printf(" _______________\n\n");
492 496
493 for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { 497 for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) {
494 struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node); 498 struct symbol *sym;
495 struct symbol *sym = (struct symbol *)(syme + 1);
496 double pcnt; 499 double pcnt;
497 500
501 syme = rb_entry(nd, struct sym_entry, rb_node);
502 sym = (struct symbol *)(syme + 1);
503
498 if (++printed > print_entries || (int)syme->snap_count < count_filter) 504 if (++printed > print_entries || (int)syme->snap_count < count_filter)
499 continue; 505 continue;
500 506
@@ -507,7 +513,9 @@ static void print_sym_table(void)
507 printf("%9.1f %10ld - ", syme->weight, syme->snap_count); 513 printf("%9.1f %10ld - ", syme->weight, syme->snap_count);
508 514
509 percent_color_fprintf(stdout, "%4.1f%%", pcnt); 515 percent_color_fprintf(stdout, "%4.1f%%", pcnt);
510 printf(" - %016llx : %s", sym->start, sym->name); 516 if (verbose)
517 printf(" - %016llx", sym->start);
518 printf(" : %s", sym->name);
511 if (sym->module) 519 if (sym->module)
512 printf("\t[%s]", sym->module->name); 520 printf("\t[%s]", sym->module->name);
513 printf("\n"); 521 printf("\n");
@@ -613,7 +621,7 @@ static void print_mapped_keys(void)
613 621
614 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); 622 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter);
615 623
616 if (vmlinux) { 624 if (vmlinux_name) {
617 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); 625 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter);
618 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); 626 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
619 fprintf(stdout, "\t[S] stop annotation.\n"); 627 fprintf(stdout, "\t[S] stop annotation.\n");
@@ -642,7 +650,9 @@ static int key_mapped(int c)
642 case 'F': 650 case 'F':
643 case 's': 651 case 's':
644 case 'S': 652 case 'S':
645 return vmlinux ? 1 : 0; 653 return vmlinux_name ? 1 : 0;
654 default:
655 break;
646 } 656 }
647 657
648 return 0; 658 return 0;
@@ -728,6 +738,8 @@ static void handle_keypress(int c)
728 case 'z': 738 case 'z':
729 zero = ~zero; 739 zero = ~zero;
730 break; 740 break;
741 default:
742 break;
731 } 743 }
732} 744}
733 745
@@ -816,13 +828,13 @@ static int parse_symbols(void)
816{ 828{
817 struct rb_node *node; 829 struct rb_node *node;
818 struct symbol *sym; 830 struct symbol *sym;
819 int modules = vmlinux ? 1 : 0; 831 int use_modules = vmlinux_name ? 1 : 0;
820 832
821 kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); 833 kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry));
822 if (kernel_dso == NULL) 834 if (kernel_dso == NULL)
823 return -1; 835 return -1;
824 836
825 if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0) 837 if (dso__load_kernel(kernel_dso, vmlinux_name, symbol_filter, verbose, use_modules) <= 0)
826 goto out_delete_dso; 838 goto out_delete_dso;
827 839
828 node = rb_first(&kernel_dso->syms); 840 node = rb_first(&kernel_dso->syms);
@@ -937,26 +949,6 @@ static void mmap_read_counter(struct mmap_data *md)
937 last_read = this_read; 949 last_read = this_read;
938 950
939 for (; old != head;) { 951 for (; old != head;) {
940 struct ip_event {
941 struct perf_event_header header;
942 u64 ip;
943 u32 pid, target_pid;
944 };
945 struct mmap_event {
946 struct perf_event_header header;
947 u32 pid, target_pid;
948 u64 start;
949 u64 len;
950 u64 pgoff;
951 char filename[PATH_MAX];
952 };
953
954 typedef union event_union {
955 struct perf_event_header header;
956 struct ip_event ip;
957 struct mmap_event mmap;
958 } event_t;
959
960 event_t *event = (event_t *)&data[old & md->mask]; 952 event_t *event = (event_t *)&data[old & md->mask];
961 953
962 event_t event_copy; 954 event_t event_copy;
@@ -1138,7 +1130,7 @@ static const struct option options[] = {
1138 "system-wide collection from all CPUs"), 1130 "system-wide collection from all CPUs"),
1139 OPT_INTEGER('C', "CPU", &profile_cpu, 1131 OPT_INTEGER('C', "CPU", &profile_cpu,
1140 "CPU to profile on"), 1132 "CPU to profile on"),
1141 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 1133 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"),
1142 OPT_INTEGER('m', "mmap-pages", &mmap_pages, 1134 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
1143 "number of mmap data pages"), 1135 "number of mmap data pages"),
1144 OPT_INTEGER('r', "realtime", &realtime_prio, 1136 OPT_INTEGER('r', "realtime", &realtime_prio,