perf report: Use ui__warning in some more places
[pandora-kernel.git] / tools / perf / builtin-report.c
index 5d43d01..d7ff277 100644 (file)
@@ -33,6 +33,8 @@
 #include "util/sort.h"
 #include "util/hist.h"
 
+#include <linux/bitmap.h>
+
 static char            const *input_name = "perf.data";
 
 static bool            force, use_tui, use_stdio;
@@ -49,6 +51,9 @@ static char           callchain_default_opt[] = "fractal,0.5,callee";
 static bool            inverted_callchain;
 static symbol_filter_t annotate_init;
 
+static const char      *cpu_list;
+static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
+
 static int perf_session__add_hist_entry(struct perf_session *session,
                                        struct addr_location *al,
                                        struct perf_sample *sample,
@@ -117,6 +122,9 @@ static int process_sample_event(union perf_event *event,
        if (al.filtered || (hide_unresolved && al.sym == NULL))
                return 0;
 
+       if (cpu_list && !test_bit(sample->cpu, cpu_bitmap))
+               return 0;
+
        if (al.map != NULL)
                al.map->dso->hit = 1;
 
@@ -154,23 +162,22 @@ static int perf_session__setup_sample_type(struct perf_session *self)
 {
        if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
                if (sort__has_parent) {
-                       fprintf(stderr, "selected --sort parent, but no"
-                                       " callchain data. Did you call"
-                                       " perf record without -g?\n");
+                       ui__warning("Selected --sort parent, but no "
+                                   "callchain data. Did you call "
+                                   "'perf record' without -g?\n");
                        return -EINVAL;
                }
                if (symbol_conf.use_callchain) {
-                       fprintf(stderr, "selected -g but no callchain data."
-                                       " Did you call perf record without"
-                                       " -g?\n");
+                       ui__warning("Selected -g but no callchain data. Did "
+                                   "you call 'perf record' without -g?\n");
                        return -1;
                }
        } else if (!dont_use_callchains && callchain_param.mode != CHAIN_NONE &&
                   !symbol_conf.use_callchain) {
                        symbol_conf.use_callchain = true;
                        if (callchain_register_param(&callchain_param) < 0) {
-                               fprintf(stderr, "Can't register callchain"
-                                               " params\n");
+                               ui__warning("Can't register callchain "
+                                           "params.\n");
                                return -EINVAL;
                        }
        }
@@ -263,6 +270,12 @@ static int __cmd_report(void)
        if (session == NULL)
                return -ENOMEM;
 
+       if (cpu_list) {
+               ret = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap);
+               if (ret)
+                       goto out_delete;
+       }
+
        if (show_threads)
                perf_read_values_init(&show_threads_values);
 
@@ -473,6 +486,7 @@ static const struct option options[] = {
                    "Only display entries resolved to a symbol"),
        OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
                    "Look for files with symbols relative to this directory"),
+       OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
        OPT_END()
 };