perf report: Fix reporting of hypervisor
[firefly-linux-kernel-4.4.55.git] / tools / perf / builtin-report.c
index 8143477b7ef755835f8ceb1ce9b1af9654c58502..88e88c510ae586070c48e6c85b7f819c556d958d 100644 (file)
@@ -33,8 +33,8 @@ static char           *vmlinux = NULL;
 
 static char            default_sort_order[] = "comm,dso";
 static char            *sort_order = default_sort_order;
-static char            *dso_list_str, *comm_list_str;
-static struct strlist  *dso_list, *comm_list;
+static char            *dso_list_str, *comm_list_str, *sym_list_str;
+static struct strlist  *dso_list, *comm_list, *sym_list;
 
 static int             input;
 static int             show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
@@ -1213,6 +1213,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
        struct map *map = NULL;
        void *more_data = event->ip.__more_data;
        struct ip_callchain *chain = NULL;
+       int cpumode;
 
        if (sample_type & PERF_SAMPLE_PERIOD) {
                period = *(u64 *)more_data;
@@ -1256,7 +1257,9 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
        if (comm_list && !strlist__has_entry(comm_list, thread->comm))
                return 0;
 
-       if (event->header.misc & PERF_EVENT_MISC_KERNEL) {
+       cpumode = event->header.misc & PERF_EVENT_MISC_CPUMODE_MASK;
+
+       if (cpumode == PERF_EVENT_MISC_KERNEL) {
                show = SHOW_KERNEL;
                level = 'k';
 
@@ -1264,7 +1267,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
 
                dprintf(" ...... dso: %s\n", dso->name);
 
-       } else if (event->header.misc & PERF_EVENT_MISC_USER) {
+       } else if (cpumode == PERF_EVENT_MISC_USER) {
 
                show = SHOW_USER;
                level = '.';
@@ -1281,6 +1284,9 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
                if (dso_list && dso && dso->name && !strlist__has_entry(dso_list, dso->name))
                        return 0;
 
+               if (sym_list && sym && !strlist__has_entry(sym_list, sym->name))
+                       return 0;
+
                if (hist_entry__add(thread, map, dso, sym, ip, chain, level, period)) {
                        eprintf("problem incrementing symbol count, skipping event\n");
                        return -1;
@@ -1672,6 +1678,8 @@ static const struct option options[] = {
                   "only consider symbols in these dsos"),
        OPT_STRING('C', "comms", &comm_list_str, "comm[,comm...]",
                   "only consider symbols in these comms"),
+       OPT_STRING('S', "symbols", &sym_list_str, "symbol[,symbol...]",
+                  "only consider these symbols"),
        OPT_END()
 };
 
@@ -1726,6 +1734,7 @@ int cmd_report(int argc, const char **argv, const char *prefix)
 
        setup_list(&dso_list, dso_list_str, "dso");
        setup_list(&comm_list, comm_list_str, "comm");
+       setup_list(&sym_list, sym_list_str, "symbol");
 
        setup_pager();