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/perf/tests | |
| 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/perf/tests')
| -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 |
4 files changed, 41 insertions, 33 deletions
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c index 0ac240db2e24..614d5c4978ab 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c | |||
| @@ -245,7 +245,7 @@ static int do_test(struct hists *hists, struct result *expected, size_t nr_expec | |||
| 245 | static int test1(struct perf_evsel *evsel, struct machine *machine) | 245 | static int test1(struct perf_evsel *evsel, struct machine *machine) |
| 246 | { | 246 | { |
| 247 | int err; | 247 | int err; |
| 248 | struct hists *hists = &evsel->hists; | 248 | struct hists *hists = evsel__hists(evsel); |
| 249 | /* | 249 | /* |
| 250 | * expected output: | 250 | * expected output: |
| 251 | * | 251 | * |
| @@ -295,7 +295,7 @@ out: | |||
| 295 | static int test2(struct perf_evsel *evsel, struct machine *machine) | 295 | static int test2(struct perf_evsel *evsel, struct machine *machine) |
| 296 | { | 296 | { |
| 297 | int err; | 297 | int err; |
| 298 | struct hists *hists = &evsel->hists; | 298 | struct hists *hists = evsel__hists(evsel); |
| 299 | /* | 299 | /* |
| 300 | * expected output: | 300 | * expected output: |
| 301 | * | 301 | * |
| @@ -442,7 +442,7 @@ out: | |||
| 442 | static int test3(struct perf_evsel *evsel, struct machine *machine) | 442 | static int test3(struct perf_evsel *evsel, struct machine *machine) |
| 443 | { | 443 | { |
| 444 | int err; | 444 | int err; |
| 445 | struct hists *hists = &evsel->hists; | 445 | struct hists *hists = evsel__hists(evsel); |
| 446 | /* | 446 | /* |
| 447 | * expected output: | 447 | * expected output: |
| 448 | * | 448 | * |
| @@ -498,7 +498,7 @@ out: | |||
| 498 | static int test4(struct perf_evsel *evsel, struct machine *machine) | 498 | static int test4(struct perf_evsel *evsel, struct machine *machine) |
| 499 | { | 499 | { |
| 500 | int err; | 500 | int err; |
| 501 | struct hists *hists = &evsel->hists; | 501 | struct hists *hists = evsel__hists(evsel); |
| 502 | /* | 502 | /* |
| 503 | * expected output: | 503 | * expected output: |
| 504 | * | 504 | * |
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c index 821f581fd930..5a31787cc6b9 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c | |||
| @@ -66,11 +66,12 @@ static int add_hist_entries(struct perf_evlist *evlist, | |||
| 66 | .ops = &hist_iter_normal, | 66 | .ops = &hist_iter_normal, |
| 67 | .hide_unresolved = false, | 67 | .hide_unresolved = false, |
| 68 | }; | 68 | }; |
| 69 | struct hists *hists = evsel__hists(evsel); | ||
| 69 | 70 | ||
| 70 | /* make sure it has no filter at first */ | 71 | /* make sure it has no filter at first */ |
| 71 | evsel->hists.thread_filter = NULL; | 72 | hists->thread_filter = NULL; |
| 72 | evsel->hists.dso_filter = NULL; | 73 | hists->dso_filter = NULL; |
| 73 | evsel->hists.symbol_filter_str = NULL; | 74 | hists->symbol_filter_str = NULL; |
| 74 | 75 | ||
| 75 | sample.pid = fake_samples[i].pid; | 76 | sample.pid = fake_samples[i].pid; |
| 76 | sample.tid = fake_samples[i].pid; | 77 | sample.tid = fake_samples[i].pid; |
| @@ -134,7 +135,7 @@ int test__hists_filter(void) | |||
| 134 | goto out; | 135 | goto out; |
| 135 | 136 | ||
| 136 | evlist__for_each(evlist, evsel) { | 137 | evlist__for_each(evlist, evsel) { |
| 137 | struct hists *hists = &evsel->hists; | 138 | struct hists *hists = evsel__hists(evsel); |
| 138 | 139 | ||
| 139 | hists__collapse_resort(hists, NULL); | 140 | hists__collapse_resort(hists, NULL); |
| 140 | hists__output_resort(hists); | 141 | hists__output_resort(hists); |
| @@ -160,7 +161,7 @@ int test__hists_filter(void) | |||
| 160 | hists->stats.total_non_filtered_period); | 161 | hists->stats.total_non_filtered_period); |
| 161 | 162 | ||
| 162 | /* now applying thread filter for 'bash' */ | 163 | /* now applying thread filter for 'bash' */ |
| 163 | evsel->hists.thread_filter = fake_samples[9].thread; | 164 | hists->thread_filter = fake_samples[9].thread; |
| 164 | hists__filter_by_thread(hists); | 165 | hists__filter_by_thread(hists); |
| 165 | 166 | ||
| 166 | if (verbose > 2) { | 167 | if (verbose > 2) { |
| @@ -185,11 +186,11 @@ int test__hists_filter(void) | |||
| 185 | hists->stats.total_non_filtered_period == 400); | 186 | hists->stats.total_non_filtered_period == 400); |
| 186 | 187 | ||
| 187 | /* remove thread filter first */ | 188 | /* remove thread filter first */ |
| 188 | evsel->hists.thread_filter = NULL; | 189 | hists->thread_filter = NULL; |
| 189 | hists__filter_by_thread(hists); | 190 | hists__filter_by_thread(hists); |
| 190 | 191 | ||
| 191 | /* now applying dso filter for 'kernel' */ | 192 | /* now applying dso filter for 'kernel' */ |
| 192 | evsel->hists.dso_filter = fake_samples[0].map->dso; | 193 | hists->dso_filter = fake_samples[0].map->dso; |
| 193 | hists__filter_by_dso(hists); | 194 | hists__filter_by_dso(hists); |
| 194 | 195 | ||
| 195 | if (verbose > 2) { | 196 | if (verbose > 2) { |
| @@ -214,7 +215,7 @@ int test__hists_filter(void) | |||
| 214 | hists->stats.total_non_filtered_period == 300); | 215 | hists->stats.total_non_filtered_period == 300); |
| 215 | 216 | ||
| 216 | /* remove dso filter first */ | 217 | /* remove dso filter first */ |
| 217 | evsel->hists.dso_filter = NULL; | 218 | hists->dso_filter = NULL; |
| 218 | hists__filter_by_dso(hists); | 219 | hists__filter_by_dso(hists); |
| 219 | 220 | ||
| 220 | /* | 221 | /* |
| @@ -224,7 +225,7 @@ int test__hists_filter(void) | |||
| 224 | * be counted as a separate entry but the sample count and | 225 | * be counted as a separate entry but the sample count and |
| 225 | * total period will be remained. | 226 | * total period will be remained. |
| 226 | */ | 227 | */ |
| 227 | evsel->hists.symbol_filter_str = "main"; | 228 | hists->symbol_filter_str = "main"; |
| 228 | hists__filter_by_symbol(hists); | 229 | hists__filter_by_symbol(hists); |
| 229 | 230 | ||
| 230 | if (verbose > 2) { | 231 | if (verbose > 2) { |
| @@ -249,8 +250,8 @@ int test__hists_filter(void) | |||
| 249 | hists->stats.total_non_filtered_period == 300); | 250 | hists->stats.total_non_filtered_period == 300); |
| 250 | 251 | ||
| 251 | /* now applying all filters at once. */ | 252 | /* now applying all filters at once. */ |
| 252 | evsel->hists.thread_filter = fake_samples[1].thread; | 253 | hists->thread_filter = fake_samples[1].thread; |
| 253 | evsel->hists.dso_filter = fake_samples[1].map->dso; | 254 | hists->dso_filter = fake_samples[1].map->dso; |
| 254 | hists__filter_by_thread(hists); | 255 | hists__filter_by_thread(hists); |
| 255 | hists__filter_by_dso(hists); | 256 | hists__filter_by_dso(hists); |
| 256 | 257 | ||
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index d4b34b0f50a2..278ba8344c23 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c | |||
| @@ -73,6 +73,8 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
| 73 | * "bash [libc] malloc" so total 9 entries will be in the tree. | 73 | * "bash [libc] malloc" so total 9 entries will be in the tree. |
| 74 | */ | 74 | */ |
| 75 | evlist__for_each(evlist, evsel) { | 75 | evlist__for_each(evlist, evsel) { |
| 76 | struct hists *hists = evsel__hists(evsel); | ||
| 77 | |||
| 76 | for (k = 0; k < ARRAY_SIZE(fake_common_samples); k++) { | 78 | for (k = 0; k < ARRAY_SIZE(fake_common_samples); k++) { |
| 77 | const union perf_event event = { | 79 | const union perf_event event = { |
| 78 | .header = { | 80 | .header = { |
| @@ -87,7 +89,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
| 87 | &sample) < 0) | 89 | &sample) < 0) |
| 88 | goto out; | 90 | goto out; |
| 89 | 91 | ||
| 90 | he = __hists__add_entry(&evsel->hists, &al, NULL, | 92 | he = __hists__add_entry(hists, &al, NULL, |
| 91 | NULL, NULL, 1, 1, 0, true); | 93 | NULL, NULL, 1, 1, 0, true); |
| 92 | if (he == NULL) | 94 | if (he == NULL) |
| 93 | goto out; | 95 | goto out; |
| @@ -111,7 +113,7 @@ static int add_hist_entries(struct perf_evlist *evlist, struct machine *machine) | |||
| 111 | &sample) < 0) | 113 | &sample) < 0) |
| 112 | goto out; | 114 | goto out; |
| 113 | 115 | ||
| 114 | he = __hists__add_entry(&evsel->hists, &al, NULL, | 116 | he = __hists__add_entry(hists, &al, NULL, |
| 115 | NULL, NULL, 1, 1, 0, true); | 117 | NULL, NULL, 1, 1, 0, true); |
| 116 | if (he == NULL) | 118 | if (he == NULL) |
| 117 | goto out; | 119 | goto out; |
| @@ -271,6 +273,7 @@ static int validate_link(struct hists *leader, struct hists *other) | |||
| 271 | int test__hists_link(void) | 273 | int test__hists_link(void) |
| 272 | { | 274 | { |
| 273 | int err = -1; | 275 | int err = -1; |
| 276 | struct hists *hists, *first_hists; | ||
| 274 | struct machines machines; | 277 | struct machines machines; |
| 275 | struct machine *machine = NULL; | 278 | struct machine *machine = NULL; |
| 276 | struct perf_evsel *evsel, *first; | 279 | struct perf_evsel *evsel, *first; |
| @@ -306,24 +309,28 @@ int test__hists_link(void) | |||
| 306 | goto out; | 309 | goto out; |
| 307 | 310 | ||
| 308 | evlist__for_each(evlist, evsel) { | 311 | evlist__for_each(evlist, evsel) { |
| 309 | hists__collapse_resort(&evsel->hists, NULL); | 312 | hists = evsel__hists(evsel); |
| 313 | hists__collapse_resort(hists, NULL); | ||
| 310 | 314 | ||
| 311 | if (verbose > 2) | 315 | if (verbose > 2) |
| 312 | print_hists_in(&evsel->hists); | 316 | print_hists_in(hists); |
| 313 | } | 317 | } |
| 314 | 318 | ||
| 315 | first = perf_evlist__first(evlist); | 319 | first = perf_evlist__first(evlist); |
| 316 | evsel = perf_evlist__last(evlist); | 320 | evsel = perf_evlist__last(evlist); |
| 317 | 321 | ||
| 322 | first_hists = evsel__hists(first); | ||
| 323 | hists = evsel__hists(evsel); | ||
| 324 | |||
| 318 | /* match common entries */ | 325 | /* match common entries */ |
| 319 | hists__match(&first->hists, &evsel->hists); | 326 | hists__match(first_hists, hists); |
| 320 | err = validate_match(&first->hists, &evsel->hists); | 327 | err = validate_match(first_hists, hists); |
| 321 | if (err) | 328 | if (err) |
| 322 | goto out; | 329 | goto out; |
| 323 | 330 | ||
| 324 | /* link common and/or dummy entries */ | 331 | /* link common and/or dummy entries */ |
| 325 | hists__link(&first->hists, &evsel->hists); | 332 | hists__link(first_hists, hists); |
| 326 | err = validate_link(&first->hists, &evsel->hists); | 333 | err = validate_link(first_hists, hists); |
| 327 | if (err) | 334 | if (err) |
| 328 | goto out; | 335 | goto out; |
| 329 | 336 | ||
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c index e3bbd6c54c1b..a748f2be1222 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c | |||
| @@ -122,7 +122,7 @@ typedef int (*test_fn_t)(struct perf_evsel *, struct machine *); | |||
| 122 | static int test1(struct perf_evsel *evsel, struct machine *machine) | 122 | static int test1(struct perf_evsel *evsel, struct machine *machine) |
| 123 | { | 123 | { |
| 124 | int err; | 124 | int err; |
| 125 | struct hists *hists = &evsel->hists; | 125 | struct hists *hists = evsel__hists(evsel); |
| 126 | struct hist_entry *he; | 126 | struct hist_entry *he; |
| 127 | struct rb_root *root; | 127 | struct rb_root *root; |
| 128 | struct rb_node *node; | 128 | struct rb_node *node; |
| @@ -159,7 +159,7 @@ static int test1(struct perf_evsel *evsel, struct machine *machine) | |||
| 159 | print_hists_out(hists); | 159 | print_hists_out(hists); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | root = &evsel->hists.entries; | 162 | root = &hists->entries; |
| 163 | node = rb_first(root); | 163 | node = rb_first(root); |
| 164 | he = rb_entry(node, struct hist_entry, rb_node); | 164 | he = rb_entry(node, struct hist_entry, rb_node); |
| 165 | TEST_ASSERT_VAL("Invalid hist entry", | 165 | TEST_ASSERT_VAL("Invalid hist entry", |
| @@ -224,7 +224,7 @@ out: | |||
| 224 | static int test2(struct perf_evsel *evsel, struct machine *machine) | 224 | static int test2(struct perf_evsel *evsel, struct machine *machine) |
| 225 | { | 225 | { |
| 226 | int err; | 226 | int err; |
| 227 | struct hists *hists = &evsel->hists; | 227 | struct hists *hists = evsel__hists(evsel); |
| 228 | struct hist_entry *he; | 228 | struct hist_entry *he; |
| 229 | struct rb_root *root; | 229 | struct rb_root *root; |
| 230 | struct rb_node *node; | 230 | struct rb_node *node; |
| @@ -259,7 +259,7 @@ static int test2(struct perf_evsel *evsel, struct machine *machine) | |||
| 259 | print_hists_out(hists); | 259 | print_hists_out(hists); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | root = &evsel->hists.entries; | 262 | root = &hists->entries; |
| 263 | node = rb_first(root); | 263 | node = rb_first(root); |
| 264 | he = rb_entry(node, struct hist_entry, rb_node); | 264 | he = rb_entry(node, struct hist_entry, rb_node); |
| 265 | TEST_ASSERT_VAL("Invalid hist entry", | 265 | TEST_ASSERT_VAL("Invalid hist entry", |
| @@ -280,7 +280,7 @@ out: | |||
| 280 | static int test3(struct perf_evsel *evsel, struct machine *machine) | 280 | static int test3(struct perf_evsel *evsel, struct machine *machine) |
| 281 | { | 281 | { |
| 282 | int err; | 282 | int err; |
| 283 | struct hists *hists = &evsel->hists; | 283 | struct hists *hists = evsel__hists(evsel); |
| 284 | struct hist_entry *he; | 284 | struct hist_entry *he; |
| 285 | struct rb_root *root; | 285 | struct rb_root *root; |
| 286 | struct rb_node *node; | 286 | struct rb_node *node; |
| @@ -313,7 +313,7 @@ static int test3(struct perf_evsel *evsel, struct machine *machine) | |||
| 313 | print_hists_out(hists); | 313 | print_hists_out(hists); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | root = &evsel->hists.entries; | 316 | root = &hists->entries; |
| 317 | node = rb_first(root); | 317 | node = rb_first(root); |
| 318 | he = rb_entry(node, struct hist_entry, rb_node); | 318 | he = rb_entry(node, struct hist_entry, rb_node); |
| 319 | TEST_ASSERT_VAL("Invalid hist entry", | 319 | TEST_ASSERT_VAL("Invalid hist entry", |
| @@ -354,7 +354,7 @@ out: | |||
| 354 | static int test4(struct perf_evsel *evsel, struct machine *machine) | 354 | static int test4(struct perf_evsel *evsel, struct machine *machine) |
| 355 | { | 355 | { |
| 356 | int err; | 356 | int err; |
| 357 | struct hists *hists = &evsel->hists; | 357 | struct hists *hists = evsel__hists(evsel); |
| 358 | struct hist_entry *he; | 358 | struct hist_entry *he; |
| 359 | struct rb_root *root; | 359 | struct rb_root *root; |
| 360 | struct rb_node *node; | 360 | struct rb_node *node; |
| @@ -391,7 +391,7 @@ static int test4(struct perf_evsel *evsel, struct machine *machine) | |||
| 391 | print_hists_out(hists); | 391 | print_hists_out(hists); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | root = &evsel->hists.entries; | 394 | root = &hists->entries; |
| 395 | node = rb_first(root); | 395 | node = rb_first(root); |
| 396 | he = rb_entry(node, struct hist_entry, rb_node); | 396 | he = rb_entry(node, struct hist_entry, rb_node); |
| 397 | TEST_ASSERT_VAL("Invalid hist entry", | 397 | TEST_ASSERT_VAL("Invalid hist entry", |
| @@ -456,7 +456,7 @@ out: | |||
| 456 | static int test5(struct perf_evsel *evsel, struct machine *machine) | 456 | static int test5(struct perf_evsel *evsel, struct machine *machine) |
| 457 | { | 457 | { |
| 458 | int err; | 458 | int err; |
| 459 | struct hists *hists = &evsel->hists; | 459 | struct hists *hists = evsel__hists(evsel); |
| 460 | struct hist_entry *he; | 460 | struct hist_entry *he; |
| 461 | struct rb_root *root; | 461 | struct rb_root *root; |
| 462 | struct rb_node *node; | 462 | struct rb_node *node; |
| @@ -494,7 +494,7 @@ static int test5(struct perf_evsel *evsel, struct machine *machine) | |||
| 494 | print_hists_out(hists); | 494 | print_hists_out(hists); |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | root = &evsel->hists.entries; | 497 | root = &hists->entries; |
| 498 | node = rb_first(root); | 498 | node = rb_first(root); |
| 499 | he = rb_entry(node, struct hist_entry, rb_node); | 499 | he = rb_entry(node, struct hist_entry, rb_node); |
| 500 | 500 | ||
