diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-17 16:09:46 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-25 08:40:37 -0400 |
| commit | efd5745e43f3aabd95d521289e0caa0e30668cf4 (patch) | |
| tree | a9ecd2cf333304509e2f2f40ed7734327644a6e5 /tools | |
| parent | ba361c92e73c771fcbbbd24c2c03c322e2de2e31 (diff) | |
perf trace: Count number of events for each thread and globally
The nr_events in trace__run was local, but we will need it in other
trace methods, move it to struct trace.
We'll also need the number of events per thread, so introduce a
nr_events method for that in struct thread_trace.
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: Namhyung Kim <namhyung@gmail.com>
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-ksutaz0mtejnf7e6az3ca1td@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/builtin-trace.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index ba055103b525..c95a3e9b0331 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
| @@ -67,6 +67,7 @@ struct thread_trace { | |||
| 67 | u64 entry_time; | 67 | u64 entry_time; |
| 68 | u64 exit_time; | 68 | u64 exit_time; |
| 69 | bool entry_pending; | 69 | bool entry_pending; |
| 70 | unsigned long nr_events; | ||
| 70 | char *entry_str; | 71 | char *entry_str; |
| 71 | }; | 72 | }; |
| 72 | 73 | ||
| @@ -77,16 +78,21 @@ static struct thread_trace *thread_trace__new(void) | |||
| 77 | 78 | ||
| 78 | static struct thread_trace *thread__trace(struct thread *thread) | 79 | static struct thread_trace *thread__trace(struct thread *thread) |
| 79 | { | 80 | { |
| 81 | struct thread_trace *ttrace; | ||
| 82 | |||
| 80 | if (thread == NULL) | 83 | if (thread == NULL) |
| 81 | goto fail; | 84 | goto fail; |
| 82 | 85 | ||
| 83 | if (thread->priv == NULL) | 86 | if (thread->priv == NULL) |
| 84 | thread->priv = thread_trace__new(); | 87 | thread->priv = thread_trace__new(); |
| 85 | 88 | ||
| 86 | if (thread->priv == NULL) | 89 | if (thread->priv == NULL) |
| 87 | goto fail; | 90 | goto fail; |
| 88 | 91 | ||
| 89 | return thread->priv; | 92 | ttrace = thread->priv; |
| 93 | ++ttrace->nr_events; | ||
| 94 | |||
| 95 | return ttrace; | ||
| 90 | fail: | 96 | fail: |
| 91 | color_fprintf(stdout, PERF_COLOR_RED, | 97 | color_fprintf(stdout, PERF_COLOR_RED, |
| 92 | "WARNING: not enough memory, dropping samples!\n"); | 98 | "WARNING: not enough memory, dropping samples!\n"); |
| @@ -102,6 +108,7 @@ struct trace { | |||
| 102 | struct perf_record_opts opts; | 108 | struct perf_record_opts opts; |
| 103 | struct machine host; | 109 | struct machine host; |
| 104 | u64 base_time; | 110 | u64 base_time; |
| 111 | unsigned long nr_events; | ||
| 105 | bool multiple_threads; | 112 | bool multiple_threads; |
| 106 | double duration_filter; | 113 | double duration_filter; |
| 107 | }; | 114 | }; |
| @@ -386,7 +393,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
| 386 | { | 393 | { |
| 387 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); | 394 | struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); |
| 388 | struct perf_evsel *evsel; | 395 | struct perf_evsel *evsel; |
| 389 | int err = -1, i, nr_events = 0, before; | 396 | int err = -1, i; |
| 397 | unsigned long before; | ||
| 390 | const bool forks = argc > 0; | 398 | const bool forks = argc > 0; |
| 391 | 399 | ||
| 392 | if (evlist == NULL) { | 400 | if (evlist == NULL) { |
| @@ -444,7 +452,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
| 444 | 452 | ||
| 445 | trace->multiple_threads = evlist->threads->map[0] == -1 || evlist->threads->nr > 1; | 453 | trace->multiple_threads = evlist->threads->map[0] == -1 || evlist->threads->nr > 1; |
| 446 | again: | 454 | again: |
| 447 | before = nr_events; | 455 | before = trace->nr_events; |
| 448 | 456 | ||
| 449 | for (i = 0; i < evlist->nr_mmaps; i++) { | 457 | for (i = 0; i < evlist->nr_mmaps; i++) { |
| 450 | union perf_event *event; | 458 | union perf_event *event; |
| @@ -454,7 +462,7 @@ again: | |||
| 454 | tracepoint_handler handler; | 462 | tracepoint_handler handler; |
| 455 | struct perf_sample sample; | 463 | struct perf_sample sample; |
| 456 | 464 | ||
| 457 | ++nr_events; | 465 | ++trace->nr_events; |
| 458 | 466 | ||
| 459 | err = perf_evlist__parse_sample(evlist, event, &sample); | 467 | err = perf_evlist__parse_sample(evlist, event, &sample); |
| 460 | if (err) { | 468 | if (err) { |
| @@ -495,7 +503,7 @@ again: | |||
| 495 | } | 503 | } |
| 496 | } | 504 | } |
| 497 | 505 | ||
| 498 | if (nr_events == before) { | 506 | if (trace->nr_events == before) { |
| 499 | if (done) | 507 | if (done) |
| 500 | goto out_delete_evlist; | 508 | goto out_delete_evlist; |
| 501 | 509 | ||
