diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-09 12:13:41 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-09 12:13:41 -0400 |
| commit | 4ea062ed431d00153af0ac370cb6fef0620e5fa1 (patch) | |
| tree | c4e7ad89b37d57751802524212291d1a8a89b7e3 /tools | |
| parent | 49c23f2d541ebf7ae5e9fff03301f4e7145cc979 (diff) | |
perf evsel: Add hists helper
Not all tools need a hists instance per perf_evsel, so lets pave the way
to remove evsel->hists while leaving a way to access the hists from a
specially allocated evsel, one that comes with space at the end where
lives the evsel.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
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-qlktkhe31w4mgtbd84035sr2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/builtin-annotate.c | 8 | ||||
| -rw-r--r-- | tools/perf/builtin-diff.c | 21 | ||||
| -rw-r--r-- | tools/perf/builtin-report.c | 18 | ||||
| -rw-r--r-- | tools/perf/builtin-top.c | 55 | ||||
| -rw-r--r-- | tools/perf/tests/hists_cumulate.c | 8 | ||||
| -rw-r--r-- | tools/perf/tests/hists_filter.c | 23 | ||||
| -rw-r--r-- | tools/perf/tests/hists_link.c | 23 | ||||
| -rw-r--r-- | tools/perf/tests/hists_output.c | 20 | ||||
| -rw-r--r-- | tools/perf/ui/browsers/hists.c | 20 | ||||
| -rw-r--r-- | tools/perf/ui/gtk/hists.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/evsel.h | 5 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 22 | ||||
| -rw-r--r-- | tools/perf/util/session.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/sort.c | 4 |
14 files changed, 132 insertions, 101 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index be5939418425..c9a119e2113d 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
| @@ -51,6 +51,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, | |||
| 51 | struct addr_location *al, | 51 | struct addr_location *al, |
| 52 | struct perf_annotate *ann) | 52 | struct perf_annotate *ann) |
| 53 | { | 53 | { |
| 54 | struct hists *hists = evsel__hists(evsel); | ||
| 54 | struct hist_entry *he; | 55 | struct hist_entry *he; |
| 55 | int ret; | 56 | int ret; |
| 56 | 57 | ||
| @@ -66,13 +67,12 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel, | |||
| 66 | return 0; | 67 | return 0; |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | he = __hists__add_entry(&evsel->hists, al, NULL, NULL, NULL, 1, 1, 0, | 70 | he = __hists__add_entry(hists, al, NULL, NULL, NULL, 1, 1, 0, true); |
| 70 | true); | ||
| 71 | if (he == NULL) | 71 | if (he == NULL) |
| 72 | return -ENOMEM; | 72 | return -ENOMEM; |
| 73 | 73 | ||
| 74 | ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); | 74 | ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); |
| 75 | hists__inc_nr_samples(&evsel->hists, true); | 75 | hists__inc_nr_samples(hists, true); |
| 76 | return ret; | 76 | return ret; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -225,7 +225,7 @@ static int __cmd_annotate(struct perf_annotate *ann) | |||
| 225 | 225 | ||
| 226 | total_nr_samples = 0; | 226 | total_nr_samples = 0; |
| 227 | evlist__for_each(session->evlist, pos) { | 227 | evlist__for_each(session->evlist, pos) { |
| 228 | struct hists *hists = &pos->hists; | 228 | struct hists *hists = evsel__hists(pos); |
| 229 | u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; | 229 | u32 nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; |
| 230 | 230 | ||
| 231 | if (nr_samples > 0) { | 231 | if (nr_samples > 0) { |
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index a3ce19f7aebd..8c5c11ca8c53 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
| @@ -327,6 +327,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, | |||
| 327 | struct machine *machine) | 327 | struct machine *machine) |
| 328 | { | 328 | { |
| 329 | struct addr_location al; | 329 | struct addr_location al; |
| 330 | struct hists *hists = evsel__hists(evsel); | ||
| 330 | 331 | ||
| 331 | if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) { | 332 | if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) { |
| 332 | pr_warning("problem processing %d event, skipping it.\n", | 333 | pr_warning("problem processing %d event, skipping it.\n", |
| @@ -334,7 +335,7 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, | |||
| 334 | return -1; | 335 | return -1; |
| 335 | } | 336 | } |
| 336 | 337 | ||
| 337 | if (hists__add_entry(&evsel->hists, &al, sample->period, | 338 | if (hists__add_entry(hists, &al, sample->period, |
| 338 | sample->weight, sample->transaction)) { | 339 | sample->weight, sample->transaction)) { |
| 339 | pr_warning("problem incrementing symbol period, skipping event\n"); | 340 | pr_warning("problem incrementing symbol period, skipping event\n"); |
| 340 | return -1; | 341 | return -1; |
| @@ -346,9 +347,9 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, | |||
| 346 | * hists__output_resort() and precompute needs the total | 347 | * hists__output_resort() and precompute needs the total |
| 347 | * period in order to sort entries by percentage delta. | 348 | * period in order to sort entries by percentage delta. |
| 348 | */ | 349 | */ |
| 349 | evsel->hists.stats.total_period += sample->period; | 350 | hists->stats.total_period += sample->period; |
| 350 | if (!al.filtered) | 351 | if (!al.filtered) |
| 351 | evsel->hists.stats.total_non_filtered_period += sample->period; | 352 | hists->stats.total_non_filtered_period += sample->period; |
| 352 | 353 | ||
| 353 | return 0; | 354 | return 0; |
| 354 | } | 355 | } |
| @@ -382,7 +383,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist) | |||
| 382 | struct perf_evsel *evsel; | 383 | struct perf_evsel *evsel; |
| 383 | 384 | ||
| 384 | evlist__for_each(evlist, evsel) { | 385 | evlist__for_each(evlist, evsel) { |
| 385 | struct hists *hists = &evsel->hists; | 386 | struct hists *hists = evsel__hists(evsel); |
| 386 | 387 | ||
| 387 | hists__collapse_resort(hists, NULL); | 388 | hists__collapse_resort(hists, NULL); |
| 388 | } | 389 | } |
| @@ -631,24 +632,26 @@ static void data_process(void) | |||
| 631 | bool first = true; | 632 | bool first = true; |
| 632 | 633 | ||
| 633 | evlist__for_each(evlist_base, evsel_base) { | 634 | evlist__for_each(evlist_base, evsel_base) { |
| 635 | struct hists *hists_base = evsel__hists(evsel_base); | ||
| 634 | struct data__file *d; | 636 | struct data__file *d; |
| 635 | int i; | 637 | int i; |
| 636 | 638 | ||
| 637 | data__for_each_file_new(i, d) { | 639 | data__for_each_file_new(i, d) { |
| 638 | struct perf_evlist *evlist = d->session->evlist; | 640 | struct perf_evlist *evlist = d->session->evlist; |
| 639 | struct perf_evsel *evsel; | 641 | struct perf_evsel *evsel; |
| 642 | struct hists *hists; | ||
| 640 | 643 | ||
| 641 | evsel = evsel_match(evsel_base, evlist); | 644 | evsel = evsel_match(evsel_base, evlist); |
| 642 | if (!evsel) | 645 | if (!evsel) |
| 643 | continue; | 646 | continue; |
| 644 | 647 | ||
| 645 | d->hists = &evsel->hists; | 648 | hists = evsel__hists(evsel); |
| 649 | d->hists = hists; | ||
| 646 | 650 | ||
| 647 | hists__match(&evsel_base->hists, &evsel->hists); | 651 | hists__match(hists_base, hists); |
| 648 | 652 | ||
| 649 | if (!show_baseline_only) | 653 | if (!show_baseline_only) |
| 650 | hists__link(&evsel_base->hists, | 654 | hists__link(hists_base, hists); |
| 651 | &evsel->hists); | ||
| 652 | } | 655 | } |
| 653 | 656 | ||
| 654 | fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n", | 657 | fprintf(stdout, "%s# Event '%s'\n#\n", first ? "" : "\n", |
| @@ -659,7 +662,7 @@ static void data_process(void) | |||
| 659 | if (verbose || data__files_cnt > 2) | 662 | if (verbose || data__files_cnt > 2) |
| 660 | data__fprintf(); | 663 | data__fprintf(); |
| 661 | 664 | ||
| 662 | hists__process(&evsel_base->hists); | 665 | hists__process(hists_base); |
| 663 | } | 666 | } |
| 664 | } | 667 | } |
| 665 | 668 | ||
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ac145fae0521..3750d635f0f7 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -288,12 +288,14 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report | |||
| 288 | evname = buf; | 288 | evname = buf; |
| 289 | 289 | ||
| 290 | for_each_group_member(pos, evsel) { | 290 | for_each_group_member(pos, evsel) { |
| 291 | const struct hists *pos_hists = evsel__hists(pos); | ||
| 292 | |||
| 291 | if (symbol_conf.filter_relative) { | 293 | if (symbol_conf.filter_relative) { |
| 292 | nr_samples += pos->hists.stats.nr_non_filtered_samples; | 294 | nr_samples += pos_hists->stats.nr_non_filtered_samples; |
| 293 | nr_events += pos->hists.stats.total_non_filtered_period; | 295 | nr_events += pos_hists->stats.total_non_filtered_period; |
| 294 | } else { | 296 | } else { |
| 295 | nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; | 297 | nr_samples += pos_hists->stats.nr_events[PERF_RECORD_SAMPLE]; |
| 296 | nr_events += pos->hists.stats.total_period; | 298 | nr_events += pos_hists->stats.total_period; |
| 297 | } | 299 | } |
| 298 | } | 300 | } |
| 299 | } | 301 | } |
| @@ -318,7 +320,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist, | |||
| 318 | struct perf_evsel *pos; | 320 | struct perf_evsel *pos; |
| 319 | 321 | ||
| 320 | evlist__for_each(evlist, pos) { | 322 | evlist__for_each(evlist, pos) { |
| 321 | struct hists *hists = &pos->hists; | 323 | struct hists *hists = evsel__hists(pos); |
| 322 | const char *evname = perf_evsel__name(pos); | 324 | const char *evname = perf_evsel__name(pos); |
