perf tools: Carry perf_event_attr bitfield throught different endians
[platform/kernel/linux-arm64.git] / tools / perf / builtin-report.c
index 8e91c6e..d58e414 100644 (file)
@@ -40,7 +40,7 @@ struct perf_report {
        struct perf_tool        tool;
        struct perf_session     *session;
        char const              *input_name;
-       bool                    force, use_tui, use_stdio;
+       bool                    force, use_tui, use_gtk, use_stdio;
        bool                    hide_unresolved;
        bool                    dont_use_callchains;
        bool                    show_full_info;
@@ -50,6 +50,7 @@ struct perf_report {
        const char              *pretty_printing_style;
        symbol_filter_t         annotate_init;
        const char              *cpu_list;
+       const char              *symbol_filter_str;
        DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
 };
 
@@ -295,12 +296,15 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
 {
        size_t ret;
        char unit;
-       unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
+       unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
+       u64 nr_events = self->stats.total_period;
 
-       nr_events = convert_unit(nr_events, &unit);
-       ret = fprintf(fp, "# Events: %lu%c", nr_events, unit);
+       nr_samples = convert_unit(nr_samples, &unit);
+       ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit);
        if (evname != NULL)
-               ret += fprintf(fp, " %s", evname);
+               ret += fprintf(fp, " of event '%s'", evname);
+
+       ret += fprintf(fp, "\n# Event count (approx.): %" PRIu64, nr_events);
        return ret + fprintf(fp, "\n#\n");
 }
 
@@ -373,16 +377,23 @@ static int __cmd_report(struct perf_report *rep)
            (kernel_map->dso->hit &&
             (kernel_kmap->ref_reloc_sym == NULL ||
              kernel_kmap->ref_reloc_sym->addr == 0))) {
-               const struct dso *kdso = kernel_map->dso;
+               const char *desc =
+                   "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
+                   "can't be resolved.";
+
+               if (kernel_map) {
+                       const struct dso *kdso = kernel_map->dso;
+                       if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
+                               desc = "If some relocation was applied (e.g. "
+                                      "kexec) symbols may be misresolved.";
+                       }
+               }
 
                ui__warning(
 "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
 "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
 "Samples in kernel modules can't be resolved as well.\n\n",
-                           RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION]) ?
-"As no suitable kallsyms nor vmlinux was found, kernel samples\n"
-"can't be resolved." :
-"If some relocation was applied (e.g. kexec) symbols may be misresolved.");
+               desc);
        }
 
        if (dump_trace) {
@@ -400,6 +411,9 @@ static int __cmd_report(struct perf_report *rep)
        list_for_each_entry(pos, &session->evlist->entries, node) {
                struct hists *hists = &pos->hists;
 
+               if (pos->idx == 0)
+                       hists->symbol_filter_str = rep->symbol_filter_str;
+
                hists__collapse_resort(hists);
                hists__output_resort(hists);
                nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE];
@@ -411,8 +425,13 @@ static int __cmd_report(struct perf_report *rep)
        }
 
        if (use_browser > 0) {
-               perf_evlist__tui_browse_hists(session->evlist, help,
-                                             NULL, NULL, 0);
+               if (use_browser == 1) {
+                       perf_evlist__tui_browse_hists(session->evlist, help,
+                                                     NULL, NULL, 0);
+               } else if (use_browser == 2) {
+                       perf_evlist__gtk_browse_hists(session->evlist, help,
+                                                     NULL, NULL, 0);
+               }
        } else
                perf_evlist__tty_browse_hists(session->evlist, rep, help);
 
@@ -569,6 +588,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
        OPT_STRING(0, "pretty", &report.pretty_printing_style, "key",
                   "pretty printing style key: normal raw"),
        OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
+       OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
        OPT_BOOLEAN(0, "stdio", &report.use_stdio,
                    "Use the stdio interface"),
        OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
@@ -591,6 +611,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
                   "only consider symbols in these comms"),
        OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
                   "only consider these symbols"),
+       OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
+                  "only show symbols that (partially) match with this filter"),
        OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str,
                   "width[,width...]",
                   "don't try to adjust column width, use these fixed values"),
@@ -624,6 +646,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
                use_browser = 0;
        else if (report.use_tui)
                use_browser = 1;
+       else if (report.use_gtk)
+               use_browser = 2;
 
        if (report.inverted_callchain)
                callchain_param.order = ORDER_CALLER;
@@ -659,11 +683,10 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
 
        }
 
-       if (strcmp(report.input_name, "-") != 0) {
+       if (strcmp(report.input_name, "-") != 0)
                setup_browser(true);
-       } else {
+       else
                use_browser = 0;
-       }
 
        /*
         * Only in the newt browser we are doing integrated annotation,
@@ -709,11 +732,16 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
        } else
                symbol_conf.exclude_other = false;
 
-       /*
-        * Any (unrecognized) arguments left?
-        */
-       if (argc)
-               usage_with_options(report_usage, options);
+       if (argc) {
+               /*
+                * Special case: if there's an argument left then assume that
+                * it's a symbol filter:
+                */
+               if (argc > 1)
+                       usage_with_options(report_usage, options);
+
+               report.symbol_filter_str = argv[0];
+       }
 
        sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);