diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-11 09:36:12 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-11 13:56:40 -0500 |
commit | a33fbd56ec83b5421090b4d8f2032f635e6a9488 (patch) | |
tree | fe5cbc7363db903130b7c4922c7e6a5204c2f5ed /tools | |
parent | 58d925dcede9e8765876707a33a3406011fe1c11 (diff) |
perf machine: Simplify synthesize_threads method
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-kvm.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 4 | ||||
-rw-r--r-- | tools/perf/util/machine.c | 6 | ||||
-rw-r--r-- | tools/perf/util/machine.h | 14 |
6 files changed, 22 insertions, 16 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index f5d2c4bccbec..346bb5909e3d 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -1544,9 +1544,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm, | |||
1544 | } | 1544 | } |
1545 | kvm->session->evlist = kvm->evlist; | 1545 | kvm->session->evlist = kvm->evlist; |
1546 | perf_session__set_id_hdr_size(kvm->session); | 1546 | perf_session__set_id_hdr_size(kvm->session); |
1547 | machine__synthesize_threads(&kvm->session->machines.host, &kvm->tool, | 1547 | machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target, |
1548 | &kvm->opts.target, kvm->evlist->threads, | 1548 | kvm->evlist->threads, false); |
1549 | perf_event__process, false); | ||
1550 | err = kvm_live_open_events(kvm); | 1549 | err = kvm_live_open_events(kvm); |
1551 | if (err) | 1550 | if (err) |
1552 | goto out; | 1551 | goto out; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 41d1f37f5348..fc68b26d58f9 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -480,8 +480,8 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) | |||
480 | perf_event__synthesize_guest_os, tool); | 480 | perf_event__synthesize_guest_os, tool); |
481 | } | 481 | } |
482 | 482 | ||
483 | err = machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads, | 483 | err = __machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads, |
484 | process_synthesized_event, opts->sample_address); | 484 | process_synthesized_event, opts->sample_address); |
485 | if (err != 0) | 485 | if (err != 0) |
486 | goto out_delete_session; | 486 | goto out_delete_session; |
487 | 487 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c3a936ef7688..8c520d9fecfc 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -950,9 +950,8 @@ static int __cmd_top(struct perf_top *top) | |||
950 | if (ret) | 950 | if (ret) |
951 | goto out_delete; | 951 | goto out_delete; |
952 | 952 | ||
953 | machine__synthesize_threads(&top->session->machines.host, &top->tool, | 953 | machine__synthesize_threads(&top->session->machines.host, &opts->target, |
954 | &opts->target, top->evlist->threads, | 954 | top->evlist->threads, false); |
955 | perf_event__process, false); | ||
956 | ret = perf_top__start_counters(top); | 955 | ret = perf_top__start_counters(top); |
957 | if (ret) | 956 | if (ret) |
958 | goto out_delete; | 957 | goto out_delete; |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 7690324824db..c3008b1c369c 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1340,8 +1340,8 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist) | |||
1340 | if (trace->host == NULL) | 1340 | if (trace->host == NULL) |
1341 | return -ENOMEM; | 1341 | return -ENOMEM; |
1342 | 1342 | ||
1343 | err = machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target, | 1343 | err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target, |
1344 | evlist->threads, trace__tool_process, false); | 1344 | evlist->threads, trace__tool_process, false); |
1345 | if (err) | 1345 | if (err) |
1346 | symbol__exit(); | 1346 | symbol__exit(); |
1347 | 1347 | ||
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 9f2c61d5a9ed..680700b6d779 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -1395,9 +1395,9 @@ int machine__for_each_thread(struct machine *machine, | |||
1395 | return rc; | 1395 | return rc; |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | int machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, | 1398 | int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, |
1399 | struct perf_target *target, struct thread_map *threads, | 1399 | struct perf_target *target, struct thread_map *threads, |
1400 | perf_event__handler_t process, bool data_mmap) | 1400 | perf_event__handler_t process, bool data_mmap) |
1401 | { | 1401 | { |
1402 | if (perf_target__has_task(target)) | 1402 | if (perf_target__has_task(target)) |
1403 | return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap); | 1403 | return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap); |
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 14a89d2aecaf..fedd1dfaf715 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h | |||
@@ -179,7 +179,15 @@ int machine__for_each_thread(struct machine *machine, | |||
179 | int (*fn)(struct thread *thread, void *p), | 179 | int (*fn)(struct thread *thread, void *p), |
180 | void *priv); | 180 | void *priv); |
181 | 181 | ||
182 | int machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, | 182 | int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, |
183 | struct perf_target *target, struct thread_map *threads, | 183 | struct perf_target *target, struct thread_map *threads, |
184 | perf_event__handler_t process, bool data_mmap); | 184 | perf_event__handler_t process, bool data_mmap); |
185 | static inline | ||
186 | int machine__synthesize_threads(struct machine *machine, struct perf_target *target, | ||
187 | struct thread_map *threads, bool data_mmap) | ||
188 | { | ||
189 | return __machine__synthesize_threads(machine, NULL, target, threads, | ||
190 | perf_event__process, data_mmap); | ||
191 | } | ||
192 | |||
185 | #endif /* __PERF_MACHINE_H */ | 193 | #endif /* __PERF_MACHINE_H */ |