perf tools: Add an option to multiplex counters in a single channel
[deliverable/linux.git] / tools / perf / builtin-record.c
index 3ce2f03f217a45a875501cbcf642832eeed822df..79f99dba5be0ce493d37c48a0fb765aca6b355b3 100644 (file)
@@ -48,6 +48,7 @@ static int                    call_graph                      = 0;
 static int                     inherit_stat                    = 0;
 static int                     no_samples                      = 0;
 static int                     sample_address                  = 0;
+static int                     multiplex                       = 0;
 
 static long                    samples;
 static struct timeval          last_read;
@@ -403,8 +404,11 @@ static void create_counter(int counter, int cpu, pid_t pid)
        if (call_graph)
                attr->sample_type       |= PERF_SAMPLE_CALLCHAIN;
 
-       if (raw_samples)
+       if (raw_samples) {
+               attr->sample_type       |= PERF_SAMPLE_TIME;
                attr->sample_type       |= PERF_SAMPLE_RAW;
+               attr->sample_type       |= PERF_SAMPLE_CPU;
+       }
 
        attr->mmap              = track;
        attr->comm              = track;
@@ -482,6 +486,9 @@ try_again:
                exit(-1);
        }
 
+       if (multiplex && fd[nr_cpu][counter] != group_fd)
+               ioctl(fd[nr_cpu][counter], PERF_COUNTER_IOC_SET_OUTPUT, group_fd);
+
        ioctl(fd[nr_cpu][counter], PERF_COUNTER_IOC_ENABLE);
 }
 
@@ -520,9 +527,6 @@ static int __cmd_record(int argc, const char **argv)
        signal(SIGCHLD, sig_handler);
        signal(SIGINT, sig_handler);
 
-       if (raw_samples)
-               read_tracing_data();
-
        if (!stat(output_name, &st) && st.st_size) {
                if (!force && !append_file) {
                        fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
@@ -550,6 +554,17 @@ static int __cmd_record(int argc, const char **argv)
        else
                header = perf_header__new();
 
+
+       if (raw_samples) {
+               read_tracing_data(attrs, nr_counters);
+       } else {
+               for (i = 0; i < nr_counters; i++) {
+                       if (attrs[i].sample_type & PERF_SAMPLE_RAW) {
+                               read_tracing_data(attrs, nr_counters);
+                               break;
+                       }
+               }
+       }
        atexit(atexit_header);
 
        if (!system_wide) {
@@ -670,6 +685,8 @@ static const struct option options[] = {
                    "Sample addresses"),
        OPT_BOOLEAN('n', "no-samples", &no_samples,
                    "don't sample"),
+       OPT_BOOLEAN('M', "multiplex", &multiplex,
+                   "multiplex counter output in a single channel"),
        OPT_END()
 };
 
This page took 0.029987 seconds and 5 git commands to generate.