perf_counter tools: Use fork and remove munmap events
[deliverable/linux.git] / Documentation / perf_counter / builtin-top.c
index 3f7778ba00bc84d72e2b13438928b16d5d952868..31c00ba99b1418426b8ee73c689723546db4eb89 100644 (file)
@@ -21,6 +21,7 @@
 #include "perf.h"
 
 #include "util/symbol.h"
+#include "util/color.h"
 #include "util/util.h"
 #include "util/rbtree.h"
 #include "util/parse-options.h"
@@ -74,8 +75,6 @@ static unsigned int           realtime_prio                   =  0;
 static int                     group                           =  0;
 static unsigned int            page_size;
 static unsigned int            mmap_pages                      =  16;
-static int                     use_mmap                        = 0;
-static int                     use_munmap                      = 0;
 static int                     freq                            = 0;
 
 static char                    *sym_filter;
@@ -253,7 +252,8 @@ static void print_sym_table(void)
        for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) {
                struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node);
                struct symbol *sym = (struct symbol *)(syme + 1);
-               float pcnt;
+               char *color = PERF_COLOR_NORMAL;
+               double pcnt;
 
                if (++printed > print_entries || syme->snap_count < count_filter)
                        continue;
@@ -261,13 +261,22 @@ static void print_sym_table(void)
                pcnt = 100.0 - (100.0 * ((sum_kevents - syme->snap_count) /
                                         sum_kevents));
 
+               /*
+                * We color high-overhead entries in red, low-overhead
+                * entries in green - and keep the middle ground normal:
+                */
+               if (pcnt >= 5.0)
+                       color = PERF_COLOR_RED;
+               if (pcnt < 0.5)
+                       color = PERF_COLOR_GREEN;
+
                if (nr_counters == 1)
-                       printf("%19.2f - %4.1f%% - %016llx : %s\n",
-                               syme->weight, pcnt, sym->start, sym->name);
+                       printf("%19.2f - ", syme->weight);
                else
-                       printf("%8.1f %10ld - %4.1f%% - %016llx : %s\n",
-                               syme->weight, syme->snap_count,
-                               pcnt, sym->start, sym->name);
+                       printf("%8.1f %10ld - ", syme->weight, syme->snap_count);
+
+               color_fprintf(stdout, color, "%4.1f%%", pcnt);
+               printf(" - %016llx : %s\n", sym->start, sym->name);
        }
 
        {
@@ -349,7 +358,7 @@ static int parse_symbols(void)
        if (kernel_dso == NULL)
                return -1;
 
-       if (dso__load_kernel(kernel_dso, NULL, symbol_filter) != 0)
+       if (dso__load_kernel(kernel_dso, NULL, symbol_filter, 1) != 0)
                goto out_delete_dso;
 
        node = rb_first(&kernel_dso->syms);
@@ -516,19 +525,6 @@ static void mmap_read(struct mmap_data *md)
                if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) {
                        if (event->header.type & PERF_SAMPLE_IP)
                                process_event(event->ip.ip, md->counter);
-               } else {
-                       switch (event->header.type) {
-                               case PERF_EVENT_MMAP:
-                               case PERF_EVENT_MUNMAP:
-                                       printf("%s: %Lu %Lu %Lu %s\n",
-                                                       event->header.type == PERF_EVENT_MMAP
-                                                       ? "mmap" : "munmap",
-                                                       event->mmap.start,
-                                                       event->mmap.len,
-                                                       event->mmap.pgoff,
-                                                       event->mmap.filename);
-                                       break;
-                       }
                }
        }
 
@@ -558,8 +554,6 @@ static int __cmd_top(void)
                        attr.config             = event_id[counter];
                        attr.sample_period      = event_count[counter];
                        attr.sample_type        = PERF_SAMPLE_IP | PERF_SAMPLE_TID;
-                       attr.mmap               = use_mmap;
-                       attr.munmap             = use_munmap;
                        attr.freq               = freq;
 
                        fd[i][counter] = sys_perf_counter_open(&attr, target_pid, cpu, group_fd, 0);
@@ -659,10 +653,6 @@ static const struct option options[] = {
                    "only display symbols matchig this pattern"),
        OPT_BOOLEAN('z', "zero", &group,
                    "zero history across updates"),
-       OPT_BOOLEAN('M', "use-mmap", &use_mmap,
-                   "track mmap events"),
-       OPT_BOOLEAN('U', "use-munmap", &use_munmap,
-                   "track munmap events"),
        OPT_INTEGER('F', "freq", &freq,
                    "profile at this frequency"),
        OPT_INTEGER('E', "entries", &print_entries,
This page took 0.038564 seconds and 5 git commands to generate.