| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | | -#include "perf.h" |
|---|
| 3 | 2 | #include "util/debug.h" |
|---|
| 3 | +#include "util/dso.h" |
|---|
| 4 | 4 | #include "util/event.h" |
|---|
| 5 | +#include "util/map.h" |
|---|
| 5 | 6 | #include "util/symbol.h" |
|---|
| 6 | 7 | #include "util/sort.h" |
|---|
| 7 | 8 | #include "util/evsel.h" |
|---|
| .. | .. |
|---|
| 79 | 80 | static int add_hist_entries(struct hists *hists, struct machine *machine) |
|---|
| 80 | 81 | { |
|---|
| 81 | 82 | struct addr_location al; |
|---|
| 82 | | - struct perf_evsel *evsel = hists_to_evsel(hists); |
|---|
| 83 | + struct evsel *evsel = hists_to_evsel(hists); |
|---|
| 83 | 84 | struct perf_sample sample = { .period = 1000, }; |
|---|
| 84 | 85 | size_t i; |
|---|
| 85 | 86 | |
|---|
| .. | .. |
|---|
| 125 | 126 | static void del_hist_entries(struct hists *hists) |
|---|
| 126 | 127 | { |
|---|
| 127 | 128 | struct hist_entry *he; |
|---|
| 128 | | - struct rb_root *root_in; |
|---|
| 129 | | - struct rb_root *root_out; |
|---|
| 129 | + struct rb_root_cached *root_in; |
|---|
| 130 | + struct rb_root_cached *root_out; |
|---|
| 130 | 131 | struct rb_node *node; |
|---|
| 131 | 132 | |
|---|
| 132 | 133 | if (hists__has(hists, need_collapse)) |
|---|
| .. | .. |
|---|
| 136 | 137 | |
|---|
| 137 | 138 | root_out = &hists->entries; |
|---|
| 138 | 139 | |
|---|
| 139 | | - while (!RB_EMPTY_ROOT(root_out)) { |
|---|
| 140 | | - node = rb_first(root_out); |
|---|
| 140 | + while (!RB_EMPTY_ROOT(&root_out->rb_root)) { |
|---|
| 141 | + node = rb_first_cached(root_out); |
|---|
| 141 | 142 | |
|---|
| 142 | 143 | he = rb_entry(node, struct hist_entry, rb_node); |
|---|
| 143 | | - rb_erase(node, root_out); |
|---|
| 144 | | - rb_erase(&he->rb_node_in, root_in); |
|---|
| 144 | + rb_erase_cached(node, root_out); |
|---|
| 145 | + rb_erase_cached(&he->rb_node_in, root_in); |
|---|
| 145 | 146 | hist_entry__delete(he); |
|---|
| 146 | 147 | } |
|---|
| 147 | 148 | } |
|---|
| 148 | 149 | |
|---|
| 149 | | -typedef int (*test_fn_t)(struct perf_evsel *, struct machine *); |
|---|
| 150 | +typedef int (*test_fn_t)(struct evsel *, struct machine *); |
|---|
| 150 | 151 | |
|---|
| 151 | 152 | #define COMM(he) (thread__comm_str(he->thread)) |
|---|
| 152 | 153 | #define DSO(he) (he->ms.map->dso->short_name) |
|---|
| .. | .. |
|---|
| 189 | 190 | * function since TEST_ASSERT_VAL() returns in case of failure. |
|---|
| 190 | 191 | */ |
|---|
| 191 | 192 | hists__collapse_resort(hists, NULL); |
|---|
| 192 | | - perf_evsel__output_resort(hists_to_evsel(hists), NULL); |
|---|
| 193 | + evsel__output_resort(hists_to_evsel(hists), NULL); |
|---|
| 193 | 194 | |
|---|
| 194 | 195 | if (verbose > 2) { |
|---|
| 195 | 196 | pr_info("use callchain: %d, cumulate callchain: %d\n", |
|---|
| .. | .. |
|---|
| 198 | 199 | print_hists_out(hists); |
|---|
| 199 | 200 | } |
|---|
| 200 | 201 | |
|---|
| 201 | | - root = &hists->entries; |
|---|
| 202 | + root = &hists->entries.rb_root; |
|---|
| 202 | 203 | for (node = rb_first(root), i = 0; |
|---|
| 203 | 204 | node && (he = rb_entry(node, struct hist_entry, rb_node)); |
|---|
| 204 | 205 | node = rb_next(node), i++) { |
|---|
| .. | .. |
|---|
| 246 | 247 | } |
|---|
| 247 | 248 | |
|---|
| 248 | 249 | /* NO callchain + NO children */ |
|---|
| 249 | | -static int test1(struct perf_evsel *evsel, struct machine *machine) |
|---|
| 250 | +static int test1(struct evsel *evsel, struct machine *machine) |
|---|
| 250 | 251 | { |
|---|
| 251 | 252 | int err; |
|---|
| 252 | 253 | struct hists *hists = evsel__hists(evsel); |
|---|
| .. | .. |
|---|
| 279 | 280 | |
|---|
| 280 | 281 | symbol_conf.use_callchain = false; |
|---|
| 281 | 282 | symbol_conf.cumulate_callchain = false; |
|---|
| 282 | | - perf_evsel__reset_sample_bit(evsel, CALLCHAIN); |
|---|
| 283 | + evsel__reset_sample_bit(evsel, CALLCHAIN); |
|---|
| 283 | 284 | |
|---|
| 284 | 285 | setup_sorting(NULL); |
|---|
| 285 | 286 | callchain_register_param(&callchain_param); |
|---|
| .. | .. |
|---|
| 297 | 298 | } |
|---|
| 298 | 299 | |
|---|
| 299 | 300 | /* callcain + NO children */ |
|---|
| 300 | | -static int test2(struct perf_evsel *evsel, struct machine *machine) |
|---|
| 301 | +static int test2(struct evsel *evsel, struct machine *machine) |
|---|
| 301 | 302 | { |
|---|
| 302 | 303 | int err; |
|---|
| 303 | 304 | struct hists *hists = evsel__hists(evsel); |
|---|
| .. | .. |
|---|
| 426 | 427 | |
|---|
| 427 | 428 | symbol_conf.use_callchain = true; |
|---|
| 428 | 429 | symbol_conf.cumulate_callchain = false; |
|---|
| 429 | | - perf_evsel__set_sample_bit(evsel, CALLCHAIN); |
|---|
| 430 | + evsel__set_sample_bit(evsel, CALLCHAIN); |
|---|
| 430 | 431 | |
|---|
| 431 | 432 | setup_sorting(NULL); |
|---|
| 432 | 433 | callchain_register_param(&callchain_param); |
|---|
| .. | .. |
|---|
| 445 | 446 | } |
|---|
| 446 | 447 | |
|---|
| 447 | 448 | /* NO callchain + children */ |
|---|
| 448 | | -static int test3(struct perf_evsel *evsel, struct machine *machine) |
|---|
| 449 | +static int test3(struct evsel *evsel, struct machine *machine) |
|---|
| 449 | 450 | { |
|---|
| 450 | 451 | int err; |
|---|
| 451 | 452 | struct hists *hists = evsel__hists(evsel); |
|---|
| .. | .. |
|---|
| 484 | 485 | |
|---|
| 485 | 486 | symbol_conf.use_callchain = false; |
|---|
| 486 | 487 | symbol_conf.cumulate_callchain = true; |
|---|
| 487 | | - perf_evsel__reset_sample_bit(evsel, CALLCHAIN); |
|---|
| 488 | + evsel__reset_sample_bit(evsel, CALLCHAIN); |
|---|
| 488 | 489 | |
|---|
| 489 | 490 | setup_sorting(NULL); |
|---|
| 490 | 491 | callchain_register_param(&callchain_param); |
|---|
| .. | .. |
|---|
| 502 | 503 | } |
|---|
| 503 | 504 | |
|---|
| 504 | 505 | /* callchain + children */ |
|---|
| 505 | | -static int test4(struct perf_evsel *evsel, struct machine *machine) |
|---|
| 506 | +static int test4(struct evsel *evsel, struct machine *machine) |
|---|
| 506 | 507 | { |
|---|
| 507 | 508 | int err; |
|---|
| 508 | 509 | struct hists *hists = evsel__hists(evsel); |
|---|
| .. | .. |
|---|
| 668 | 669 | |
|---|
| 669 | 670 | symbol_conf.use_callchain = true; |
|---|
| 670 | 671 | symbol_conf.cumulate_callchain = true; |
|---|
| 671 | | - perf_evsel__set_sample_bit(evsel, CALLCHAIN); |
|---|
| 672 | + evsel__set_sample_bit(evsel, CALLCHAIN); |
|---|
| 672 | 673 | |
|---|
| 673 | 674 | setup_sorting(NULL); |
|---|
| 674 | 675 | |
|---|
| .. | .. |
|---|
| 693 | 694 | int err = TEST_FAIL; |
|---|
| 694 | 695 | struct machines machines; |
|---|
| 695 | 696 | struct machine *machine; |
|---|
| 696 | | - struct perf_evsel *evsel; |
|---|
| 697 | | - struct perf_evlist *evlist = perf_evlist__new(); |
|---|
| 697 | + struct evsel *evsel; |
|---|
| 698 | + struct evlist *evlist = evlist__new(); |
|---|
| 698 | 699 | size_t i; |
|---|
| 699 | 700 | test_fn_t testcases[] = { |
|---|
| 700 | 701 | test1, |
|---|
| .. | .. |
|---|
| 720 | 721 | if (verbose > 1) |
|---|
| 721 | 722 | machine__fprintf(machine, stderr); |
|---|
| 722 | 723 | |
|---|
| 723 | | - evsel = perf_evlist__first(evlist); |
|---|
| 724 | + evsel = evlist__first(evlist); |
|---|
| 724 | 725 | |
|---|
| 725 | 726 | for (i = 0; i < ARRAY_SIZE(testcases); i++) { |
|---|
| 726 | 727 | err = testcases[i](evsel, machine); |
|---|
| .. | .. |
|---|
| 730 | 731 | |
|---|
| 731 | 732 | out: |
|---|
| 732 | 733 | /* tear down everything */ |
|---|
| 733 | | - perf_evlist__delete(evlist); |
|---|
| 734 | + evlist__delete(evlist); |
|---|
| 734 | 735 | machines__exit(&machines); |
|---|
| 735 | 736 | |
|---|
| 736 | 737 | return err; |
|---|