diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-11 09:28:02 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-11 13:56:39 -0500 |
commit | 58d925dcede9e8765876707a33a3406011fe1c11 (patch) | |
tree | f2fe20989a9d7be863f746d970e999d3f1ec3458 /tools | |
parent | 62605dc50c27bf0e4ff69b7b3166f226586aff02 (diff) |
perf machine: Introduce synthesize_threads method out of open coded equivalent
Further simplifications to be done on following patch, as most tools
don't use the callback, using instead just the canned
machine__process_event one.
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-r1m0vuuj3cat4bampno9yc8d@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 | 15 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 12 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 11 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 11 | ||||
-rw-r--r-- | tools/perf/util/machine.c | 12 | ||||
-rw-r--r-- | tools/perf/util/machine.h | 4 |
6 files changed, 26 insertions, 39 deletions
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index f36e8209c300..f5d2c4bccbec 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -1544,18 +1544,9 @@ 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 | 1547 | machine__synthesize_threads(&kvm->session->machines.host, &kvm->tool, | |
1548 | 1548 | &kvm->opts.target, kvm->evlist->threads, | |
1549 | if (perf_target__has_task(&kvm->opts.target)) | 1549 | perf_event__process, false); |
1550 | perf_event__synthesize_thread_map(&kvm->tool, | ||
1551 | kvm->evlist->threads, | ||
1552 | perf_event__process, | ||
1553 | &kvm->session->machines.host, false); | ||
1554 | else | ||
1555 | perf_event__synthesize_threads(&kvm->tool, perf_event__process, | ||
1556 | &kvm->session->machines.host, false); | ||
1557 | |||
1558 | |||
1559 | err = kvm_live_open_events(kvm); | 1550 | err = kvm_live_open_events(kvm); |
1560 | if (err) | 1551 | if (err) |
1561 | goto out; | 1552 | goto out; |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index afb252cf6eca..41d1f37f5348 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -480,16 +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 | if (perf_target__has_task(&opts->target)) | 483 | err = machine__synthesize_threads(machine, tool, &opts->target, evsel_list->threads, |
484 | err = perf_event__synthesize_thread_map(tool, evsel_list->threads, | 484 | process_synthesized_event, opts->sample_address); |
485 | process_synthesized_event, | ||
486 | machine, opts->sample_address); | ||
487 | else if (perf_target__has_cpu(&opts->target)) | ||
488 | err = perf_event__synthesize_threads(tool, process_synthesized_event, | ||
489 | machine, opts->sample_address); | ||
490 | else /* command specified */ | ||
491 | err = 0; | ||
492 | |||
493 | if (err != 0) | 485 | if (err != 0) |
494 | goto out_delete_session; | 486 | goto out_delete_session; |
495 | 487 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index cc96d753db96..c3a936ef7688 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -950,14 +950,9 @@ 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 | if (perf_target__has_task(&opts->target)) | 953 | machine__synthesize_threads(&top->session->machines.host, &top->tool, |
954 | perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, | 954 | &opts->target, top->evlist->threads, |
955 | perf_event__process, | 955 | perf_event__process, false); |
956 | &top->session->machines.host, false); | ||
957 | else | ||
958 | perf_event__synthesize_threads(&top->tool, perf_event__process, | ||
959 | &top->session->machines.host, false); | ||
960 | |||
961 | ret = perf_top__start_counters(top); | 956 | ret = perf_top__start_counters(top); |
962 | if (ret) | 957 | if (ret) |
963 | goto out_delete; | 958 | goto out_delete; |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 277c2367e0cf..7690324824db 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1340,15 +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 | if (perf_target__has_task(&trace->opts.target)) { | 1343 | err = machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target, |
1344 | err = perf_event__synthesize_thread_map(&trace->tool, evlist->threads, | 1344 | evlist->threads, trace__tool_process, false); |
1345 | trace__tool_process, | ||
1346 | trace->host, false); | ||
1347 | } else { | ||
1348 | err = perf_event__synthesize_threads(&trace->tool, trace__tool_process, | ||
1349 | trace->host, false); | ||
1350 | } | ||
1351 | |||
1352 | if (err) | 1345 | if (err) |
1353 | symbol__exit(); | 1346 | symbol__exit(); |
1354 | 1347 | ||
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index ce034c183a7e..9f2c61d5a9ed 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -1394,3 +1394,15 @@ int machine__for_each_thread(struct machine *machine, | |||
1394 | } | 1394 | } |
1395 | return rc; | 1395 | return rc; |
1396 | } | 1396 | } |
1397 | |||
1398 | int machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, | ||
1399 | struct perf_target *target, struct thread_map *threads, | ||
1400 | perf_event__handler_t process, bool data_mmap) | ||
1401 | { | ||
1402 | if (perf_target__has_task(target)) | ||
1403 | return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap); | ||
1404 | else if (perf_target__has_cpu(target)) | ||
1405 | return perf_event__synthesize_threads(tool, process, machine, data_mmap); | ||
1406 | /* command specified */ | ||
1407 | return 0; | ||
1408 | } | ||
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 2389ba81fafe..14a89d2aecaf 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <sys/types.h> | 4 | #include <sys/types.h> |
5 | #include <linux/rbtree.h> | 5 | #include <linux/rbtree.h> |
6 | #include "map.h" | 6 | #include "map.h" |
7 | #include "event.h" | ||
7 | 8 | ||
8 | struct addr_location; | 9 | struct addr_location; |
9 | struct branch_stack; | 10 | struct branch_stack; |
@@ -178,4 +179,7 @@ int machine__for_each_thread(struct machine *machine, | |||
178 | int (*fn)(struct thread *thread, void *p), | 179 | int (*fn)(struct thread *thread, void *p), |
179 | void *priv); | 180 | void *priv); |
180 | 181 | ||
182 | int machine__synthesize_threads(struct machine *machine, struct perf_tool *tool, | ||
183 | struct perf_target *target, struct thread_map *threads, | ||
184 | perf_event__handler_t process, bool data_mmap); | ||
181 | #endif /* __PERF_MACHINE_H */ | 185 | #endif /* __PERF_MACHINE_H */ |