perf tools: Use target->per_thread and target->system_wide flags
[linux-2.6-microblaze.git] / tools / perf / util / evlist.c
index ac35cd2..7b7d535 100644 (file)
@@ -715,28 +715,11 @@ union perf_event *perf_evlist__mmap_read_forward(struct perf_evlist *evlist, int
        return perf_mmap__read_forward(md);
 }
 
-union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, int idx)
-{
-       struct perf_mmap *md = &evlist->mmap[idx];
-
-       /*
-        * No need to check messup for backward ring buffer:
-        * We can always read arbitrary long data from a backward
-        * ring buffer unless we forget to pause it before reading.
-        */
-       return perf_mmap__read_backward(md);
-}
-
 union perf_event *perf_evlist__mmap_read(struct perf_evlist *evlist, int idx)
 {
        return perf_evlist__mmap_read_forward(evlist, idx);
 }
 
-void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx)
-{
-       perf_mmap__read_catchup(&evlist->mmap[idx]);
-}
-
 void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx)
 {
        perf_mmap__consume(&evlist->mmap[idx], false);
@@ -1103,11 +1086,30 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages)
 
 int perf_evlist__create_maps(struct perf_evlist *evlist, struct target *target)
 {
+       bool all_threads = (target->per_thread && target->system_wide);
        struct cpu_map *cpus;
        struct thread_map *threads;
 
+       /*
+        * If specify '-a' and '--per-thread' to perf record, perf record
+        * will override '--per-thread'. target->per_thread = false and
+        * target->system_wide = true.
+        *
+        * If specify '--per-thread' only to perf record,
+        * target->per_thread = true and target->system_wide = false.
+        *
+        * So target->per_thread && target->system_wide is false.
+        * For perf record, thread_map__new_str doesn't call
+        * thread_map__new_all_cpus. That will keep perf record's
+        * current behavior.
+        *
+        * For perf stat, it allows the case that target->per_thread and
+        * target->system_wide are all true. It means to collect system-wide
+        * per-thread data. thread_map__new_str will call
+        * thread_map__new_all_cpus to enumerate all threads.
+        */
        threads = thread_map__new_str(target->pid, target->tid, target->uid,
-                                     target->per_thread);
+                                     all_threads);
 
        if (!threads)
                return -1;