perf machine: Simplify synthesize_threads method
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Nov 2013 14:36:12 +0000 (11:36 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Nov 2013 18:56:40 +0000 (15:56 -0300)
Several tools (top, kvm) don't need to be called back to process each of
the syntheiszed records, instead relying on the machine__process_event
function to change the per machine data structures that represent
threads and mmaps, so provide a way to ask for this common idiom.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-pusqibp8n3c4ynegd1frn4zd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-kvm.c
tools/perf/builtin-record.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/util/machine.c
tools/perf/util/machine.h

index f5d2c4bccbec57a179f35a56ba1ed8935ad53a7a..346bb5909e3dd2ee52b92e6dbb829d7bfdff2ca1 100644 (file)
@@ -1544,9 +1544,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
        }
        kvm->session->evlist = kvm->evlist;
        perf_session__set_id_hdr_size(kvm->session);
-       machine__synthesize_threads(&kvm->session->machines.host, &kvm->tool,
-                                   &kvm->opts.target, kvm->evlist->threads,
-                                   perf_event__process, false);
+       machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target,
+                                   kvm->evlist->threads, false);
        err = kvm_live_open_events(kvm);
        if (err)
                goto out;
index 41d1f37f53484e4f74709b4676b93cfff480ebc7..fc68b26d58f98c34989a5437b3d1e6add7d0ba04 100644 (file)
@@ -480,8 +480,8 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
                                         perf_event__synthesize_guest_os, tool);
        }
 
-       err = machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads,
-                                         process_synthesized_event, opts->sample_address);
+       err = __machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads,
+                                           process_synthesized_event, opts->sample_address);
        if (err != 0)
                goto out_delete_session;
 
index c3a936ef76885d24e26e4ce8c0704f96943df143..8c520d9fecfca886c14913de8932e2cd69698e26 100644 (file)
@@ -950,9 +950,8 @@ static int __cmd_top(struct perf_top *top)
        if (ret)
                goto out_delete;
 
-       machine__synthesize_threads(&top->session->machines.host, &top->tool,
-                                   &opts->target, top->evlist->threads,
-                                   perf_event__process, false);
+       machine__synthesize_threads(&top->session->machines.host, &opts->target,
+                                   top->evlist->threads, false);
        ret = perf_top__start_counters(top);
        if (ret)
                goto out_delete;
index 7690324824db6b19c5ec60823be608d8a6bfc52d..c3008b1c369cc49e6c6b02d1071e0bcbde9b6346 100644 (file)
@@ -1340,8 +1340,8 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
        if (trace->host == NULL)
                return -ENOMEM;
 
-       err = machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
-                                         evlist->threads, trace__tool_process, false);
+       err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
+                                           evlist->threads, trace__tool_process, false);
        if (err)
                symbol__exit();
 
index 9f2c61d5a9ed625018d98f281be3aa25ef34cc3e..680700b6d779f000f6ca1ab3bba9834b13f30179 100644 (file)
@@ -1395,9 +1395,9 @@ int machine__for_each_thread(struct machine *machine,
        return rc;
 }
 
-int machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
-                               struct perf_target *target, struct thread_map *threads,
-                               perf_event__handler_t process, bool data_mmap)
+int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
+                                 struct perf_target *target, struct thread_map *threads,
+                                 perf_event__handler_t process, bool data_mmap)
 {
        if (perf_target__has_task(target))
                return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
index 14a89d2aecaf266fc685e1d87e0243f13c9a9e5a..fedd1dfaf715ebfbf907959ad07d11ddd21a26cc 100644 (file)
@@ -179,7 +179,15 @@ int machine__for_each_thread(struct machine *machine,
                             int (*fn)(struct thread *thread, void *p),
                             void *priv);
 
-int machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
-                               struct perf_target *target, struct thread_map *threads,
-                               perf_event__handler_t process, bool data_mmap);
+int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
+                                 struct perf_target *target, struct thread_map *threads,
+                                 perf_event__handler_t process, bool data_mmap);
+static inline
+int machine__synthesize_threads(struct machine *machine, struct perf_target *target,
+                               struct thread_map *threads, bool data_mmap)
+{
+       return __machine__synthesize_threads(machine, NULL, target, threads,
+                                            perf_event__process, data_mmap);
+}
+
 #endif /* __PERF_MACHINE_H */