diff options
-rw-r--r-- | tools/perf/builtin-record.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-test.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evlist.c | 40 | ||||
-rw-r--r-- | tools/perf/util/evlist.h | 23 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 5 | ||||
-rw-r--r-- | tools/perf/util/header.c | 4 | ||||
-rw-r--r-- | tools/perf/util/parse-events-test.c | 129 | ||||
-rw-r--r-- | tools/perf/util/parse-events.c | 2 | ||||
-rw-r--r-- | tools/perf/util/top.c | 3 |
11 files changed, 95 insertions, 125 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index c4e3b683e79b..479ff2a038fc 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -172,12 +172,12 @@ static bool perf_evlist__equal(struct perf_evlist *evlist, | |||
172 | if (evlist->nr_entries != other->nr_entries) | 172 | if (evlist->nr_entries != other->nr_entries) |
173 | return false; | 173 | return false; |
174 | 174 | ||
175 | pair = list_entry(other->entries.next, struct perf_evsel, node); | 175 | pair = perf_evlist__first(other); |
176 | 176 | ||
177 | list_for_each_entry(pos, &evlist->entries, node) { | 177 | list_for_each_entry(pos, &evlist->entries, node) { |
178 | if (memcmp(&pos->attr, &pair->attr, sizeof(pos->attr) != 0)) | 178 | if (memcmp(&pos->attr, &pair->attr, sizeof(pos->attr) != 0)) |
179 | return false; | 179 | return false; |
180 | pair = list_entry(pair->node.next, struct perf_evsel, node); | 180 | pair = perf_evsel__next(pair); |
181 | } | 181 | } |
182 | 182 | ||
183 | return true; | 183 | return true; |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 7b9c46341e02..d53d8ab099b1 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -480,7 +480,7 @@ static int run_perf_stat(int argc __used, const char **argv) | |||
480 | if (group) | 480 | if (group) |
481 | perf_evlist__set_leader(evsel_list); | 481 | perf_evlist__set_leader(evsel_list); |
482 | 482 | ||
483 | first = list_entry(evsel_list->entries.next, struct perf_evsel, node); | 483 | first = perf_evlist__first(evsel_list); |
484 | 484 | ||
485 | list_for_each_entry(counter, &evsel_list->entries, node) { | 485 | list_for_each_entry(counter, &evsel_list->entries, node) { |
486 | if (create_perf_stat_counter(counter, first) < 0) { | 486 | if (create_perf_stat_counter(counter, first) < 0) { |
diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 9a479b68fc9b..381d5ab87124 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c | |||
@@ -710,7 +710,7 @@ static int test__PERF_RECORD(void) | |||
710 | /* | 710 | /* |
711 | * Config the evsels, setting attr->comm on the first one, etc. | 711 | * Config the evsels, setting attr->comm on the first one, etc. |
712 | */ | 712 | */ |
713 | evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | 713 | evsel = perf_evlist__first(evlist); |
714 | evsel->attr.sample_type |= PERF_SAMPLE_CPU; | 714 | evsel->attr.sample_type |= PERF_SAMPLE_CPU; |
715 | evsel->attr.sample_type |= PERF_SAMPLE_TID; | 715 | evsel->attr.sample_type |= PERF_SAMPLE_TID; |
716 | evsel->attr.sample_type |= PERF_SAMPLE_TIME; | 716 | evsel->attr.sample_type |= PERF_SAMPLE_TIME; |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 5a097beb8685..0513aaa659f9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -509,7 +509,7 @@ static void perf_top__handle_keypress(struct perf_top *top, int c) | |||
509 | prompt_integer(&counter, "Enter details event counter"); | 509 | prompt_integer(&counter, "Enter details event counter"); |
510 | 510 | ||
511 | if (counter >= top->evlist->nr_entries) { | 511 | if (counter >= top->evlist->nr_entries) { |
512 | top->sym_evsel = list_entry(top->evlist->entries.next, struct perf_evsel, node); | 512 | top->sym_evsel = perf_evlist__first(top->evlist); |
513 | fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel)); | 513 | fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel)); |
514 | sleep(1); | 514 | sleep(1); |
515 | break; | 515 | break; |
@@ -518,7 +518,7 @@ static void perf_top__handle_keypress(struct perf_top *top, int c) | |||
518 | if (top->sym_evsel->idx == counter) | 518 | if (top->sym_evsel->idx == counter) |
519 | break; | 519 | break; |
520 | } else | 520 | } else |
521 | top->sym_evsel = list_entry(top->evlist->entries.next, struct perf_evsel, node); | 521 | top->sym_evsel = perf_evlist__first(top->evlist); |
522 | break; | 522 | break; |
523 | case 'f': | 523 | case 'f': |
524 | prompt_integer(&top->count_filter, "Enter display event count filter"); | 524 | prompt_integer(&top->count_filter, "Enter display event count filter"); |
@@ -1326,7 +1326,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1326 | pos->attr.sample_period = top.default_interval; | 1326 | pos->attr.sample_period = top.default_interval; |
1327 | } | 1327 | } |
1328 | 1328 | ||
1329 | top.sym_evsel = list_entry(top.evlist->entries.next, struct perf_evsel, node); | 1329 | top.sym_evsel = perf_evlist__first(top.evlist); |
1330 | 1330 | ||
1331 | symbol_conf.priv_size = sizeof(struct annotation); | 1331 | symbol_conf.priv_size = sizeof(struct annotation); |
1332 | 1332 | ||
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 6d09451430d2..4774ac1e3d5f 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -57,7 +57,7 @@ void perf_evlist__config_attrs(struct perf_evlist *evlist, | |||
57 | if (evlist->cpus->map[0] < 0) | 57 | if (evlist->cpus->map[0] < 0) |
58 | opts->no_inherit = true; | 58 | opts->no_inherit = true; |
59 | 59 | ||
60 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | 60 | first = perf_evlist__first(evlist); |
61 | 61 | ||
62 | list_for_each_entry(evsel, &evlist->entries, node) { | 62 | list_for_each_entry(evsel, &evlist->entries, node) { |
63 | perf_evsel__config(evsel, opts, first); | 63 | perf_evsel__config(evsel, opts, first); |
@@ -376,7 +376,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) | |||
376 | int hash; | 376 | int hash; |
377 | 377 | ||
378 | if (evlist->nr_entries == 1) | 378 | if (evlist->nr_entries == 1) |
379 | return list_entry(evlist->entries.next, struct perf_evsel, node); | 379 | return perf_evlist__first(evlist); |
380 | 380 | ||
381 | hash = hash_64(id, PERF_EVLIST__HLIST_BITS); | 381 | hash = hash_64(id, PERF_EVLIST__HLIST_BITS); |
382 | head = &evlist->heads[hash]; | 382 | head = &evlist->heads[hash]; |
@@ -386,7 +386,7 @@ struct perf_evsel *perf_evlist__id2evsel(struct perf_evlist *evlist, u64 id) | |||
386 | return sid->evsel; | 386 | return sid->evsel; |
387 | 387 | ||
388 | if (!perf_evlist__sample_id_all(evlist)) | 388 | if (!perf_evlist__sample_id_all(evlist)) |
389 | return list_entry(evlist->entries.next, struct perf_evsel, node); | 389 | return perf_evlist__first(evlist); |
390 | 390 | ||
391 | return NULL; | 391 | return NULL; |
392 | } | 392 | } |
@@ -694,11 +694,9 @@ int perf_evlist__set_filters(struct perf_evlist *evlist) | |||
694 | return 0; | 694 | return 0; |
695 | } | 695 | } |
696 | 696 | ||
697 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist) | 697 | bool perf_evlist__valid_sample_type(struct perf_evlist *evlist) |
698 | { | 698 | { |
699 | struct perf_evsel *pos, *first; | 699 | struct perf_evsel *first = perf_evlist__first(evlist), *pos = first; |
700 | |||
701 | pos = first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
702 | 700 | ||
703 | list_for_each_entry_continue(pos, &evlist->entries, node) { | 701 | list_for_each_entry_continue(pos, &evlist->entries, node) { |
704 | if (first->attr.sample_type != pos->attr.sample_type) | 702 | if (first->attr.sample_type != pos->attr.sample_type) |
@@ -708,23 +706,19 @@ bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist) | |||
708 | return true; | 706 | return true; |
709 | } | 707 | } |
710 | 708 | ||
711 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist) | 709 | u64 perf_evlist__sample_type(struct perf_evlist *evlist) |
712 | { | 710 | { |
713 | struct perf_evsel *first; | 711 | struct perf_evsel *first = perf_evlist__first(evlist); |
714 | |||
715 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
716 | return first->attr.sample_type; | 712 | return first->attr.sample_type; |
717 | } | 713 | } |
718 | 714 | ||
719 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist) | 715 | u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist) |
720 | { | 716 | { |
721 | struct perf_evsel *first; | 717 | struct perf_evsel *first = perf_evlist__first(evlist); |
722 | struct perf_sample *data; | 718 | struct perf_sample *data; |
723 | u64 sample_type; | 719 | u64 sample_type; |
724 | u16 size = 0; | 720 | u16 size = 0; |
725 | 721 | ||
726 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
727 | |||
728 | if (!first->attr.sample_id_all) | 722 | if (!first->attr.sample_id_all) |
729 | goto out; | 723 | goto out; |
730 | 724 | ||
@@ -748,11 +742,9 @@ out: | |||
748 | return size; | 742 | return size; |
749 | } | 743 | } |
750 | 744 | ||
751 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist) | 745 | bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist) |
752 | { | 746 | { |
753 | struct perf_evsel *pos, *first; | 747 | struct perf_evsel *first = perf_evlist__first(evlist), *pos = first; |
754 | |||
755 | pos = first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
756 | 748 | ||
757 | list_for_each_entry_continue(pos, &evlist->entries, node) { | 749 | list_for_each_entry_continue(pos, &evlist->entries, node) { |
758 | if (first->attr.sample_id_all != pos->attr.sample_id_all) | 750 | if (first->attr.sample_id_all != pos->attr.sample_id_all) |
@@ -762,11 +754,9 @@ bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist) | |||
762 | return true; | 754 | return true; |
763 | } | 755 | } |
764 | 756 | ||
765 | bool perf_evlist__sample_id_all(const struct perf_evlist *evlist) | 757 | bool perf_evlist__sample_id_all(struct perf_evlist *evlist) |
766 | { | 758 | { |
767 | struct perf_evsel *first; | 759 | struct perf_evsel *first = perf_evlist__first(evlist); |
768 | |||
769 | first = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
770 | return first->attr.sample_id_all; | 760 | return first->attr.sample_id_all; |
771 | } | 761 | } |
772 | 762 | ||
@@ -896,6 +886,6 @@ int perf_evlist__start_workload(struct perf_evlist *evlist) | |||
896 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, | 886 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
897 | struct perf_sample *sample, bool swapped) | 887 | struct perf_sample *sample, bool swapped) |
898 | { | 888 | { |
899 | struct perf_evsel *e = list_entry(evlist->entries.next, struct perf_evsel, node); | 889 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
900 | return perf_evsel__parse_sample(e, event, sample, swapped); | 890 | return perf_evsel__parse_sample(evsel, event, sample, swapped); |
901 | } | 891 | } |
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 7fe677e6c314..2ed255792c6b 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include "../perf.h" | 6 | #include "../perf.h" |
7 | #include "event.h" | 7 | #include "event.h" |
8 | #include "evsel.h" | ||
8 | #include "util.h" | 9 | #include "util.h" |
9 | #include <unistd.h> | 10 | #include <unistd.h> |
10 | 11 | ||
@@ -41,8 +42,6 @@ struct perf_evsel_str_handler { | |||
41 | void *handler; | 42 | void *handler; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | struct perf_evsel; | ||
45 | |||
46 | struct perf_evlist *perf_evlist__new(struct cpu_map *cpus, | 45 | struct perf_evlist *perf_evlist__new(struct cpu_map *cpus, |
47 | struct thread_map *threads); | 46 | struct thread_map *threads); |
48 | void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, | 47 | void perf_evlist__init(struct perf_evlist *evlist, struct cpu_map *cpus, |
@@ -121,17 +120,27 @@ int perf_evlist__set_filters(struct perf_evlist *evlist); | |||
121 | void __perf_evlist__set_leader(struct list_head *list); | 120 | void __perf_evlist__set_leader(struct list_head *list); |
122 | void perf_evlist__set_leader(struct perf_evlist *evlist); | 121 | void perf_evlist__set_leader(struct perf_evlist *evlist); |
123 | 122 | ||
124 | u64 perf_evlist__sample_type(const struct perf_evlist *evlist); | 123 | u64 perf_evlist__sample_type(struct perf_evlist *evlist); |
125 | bool perf_evlist__sample_id_all(const const struct perf_evlist *evlist); | 124 | bool perf_evlist__sample_id_all(struct perf_evlist *evlist); |
126 | u16 perf_evlist__id_hdr_size(const struct perf_evlist *evlist); | 125 | u16 perf_evlist__id_hdr_size(struct perf_evlist *evlist); |
127 | 126 | ||
128 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, | 127 | int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, |
129 | struct perf_sample *sample, bool swapped); | 128 | struct perf_sample *sample, bool swapped); |
130 | 129 | ||
131 | bool perf_evlist__valid_sample_type(const struct perf_evlist *evlist); | 130 | bool perf_evlist__valid_sample_type(struct perf_evlist *evlist); |
132 | bool perf_evlist__valid_sample_id_all(const struct perf_evlist *evlist); | 131 | bool perf_evlist__valid_sample_id_all(struct perf_evlist *evlist); |
133 | 132 | ||
134 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, | 133 | void perf_evlist__splice_list_tail(struct perf_evlist *evlist, |
135 | struct list_head *list, | 134 | struct list_head *list, |
136 | int nr_entries); | 135 | int nr_entries); |
136 | |||
137 | static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist) | ||
138 | { | ||
139 | return list_entry(evlist->entries.next, struct perf_evsel, node); | ||
140 | } | ||
141 | |||
142 | static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist) | ||
143 | { | ||
144 | return list_entry(evlist->entries.prev, struct perf_evsel, node); | ||
145 | } | ||
137 | #endif /* __PERF_EVLIST_H */ | 146 | #endif /* __PERF_EVLIST_H */ |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index c411b421c888..65f39fdf821a 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -184,4 +184,9 @@ void hists__init(struct hists *hists); | |||
184 | 184 | ||
185 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, | 185 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, |
186 | struct perf_sample *sample, bool swapped); | 186 | struct perf_sample *sample, bool swapped); |
187 | |||
188 | static inline struct perf_evsel *perf_evsel__next(struct perf_evsel *evsel) | ||
189 | { | ||
190 | return list_entry(evsel->node.next, struct perf_evsel, node); | ||
191 | } | ||
187 | #endif /* __PERF_EVSEL_H */ | 192 | #endif /* __PERF_EVSEL_H */ |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 7e7d34fc5572..77832b807eff 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -1689,7 +1689,7 @@ int perf_session__write_header(struct perf_session *session, | |||
1689 | lseek(fd, sizeof(f_header), SEEK_SET); | 1689 | lseek(fd, sizeof(f_header), SEEK_SET); |
1690 | 1690 | ||
1691 | if (session->evlist != evlist) | 1691 | if (session->evlist != evlist) |
1692 | pair = list_entry(session->evlist->entries.next, struct perf_evsel, node); | 1692 | pair = perf_evlist__first(session->evlist); |
1693 | 1693 | ||
1694 | list_for_each_entry(attr, &evlist->entries, node) { | 1694 | list_for_each_entry(attr, &evlist->entries, node) { |
1695 | attr->id_offset = lseek(fd, 0, SEEK_CUR); | 1695 | attr->id_offset = lseek(fd, 0, SEEK_CUR); |
@@ -1704,7 +1704,7 @@ out_err_write: | |||
1704 | if (err < 0) | 1704 | if (err < 0) |
1705 | goto out_err_write; | 1705 | goto out_err_write; |
1706 | attr->ids += pair->ids; | 1706 | attr->ids += pair->ids; |
1707 | pair = list_entry(pair->node.next, struct perf_evsel, node); | 1707 | pair = perf_evsel__next(pair); |
1708 | } | 1708 | } |
1709 | } | 1709 | } |
1710 | 1710 | ||
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c index 429dd688281a..bf055ce1916e 100644 --- a/tools/perf/util/parse-events-test.c +++ b/tools/perf/util/parse-events-test.c | |||
@@ -18,8 +18,7 @@ do { \ | |||
18 | 18 | ||
19 | static int test__checkevent_tracepoint(struct perf_evlist *evlist) | 19 | static int test__checkevent_tracepoint(struct perf_evlist *evlist) |
20 | { | 20 | { |
21 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 21 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
22 | struct perf_evsel, node); | ||
23 | 22 | ||
24 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 23 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
25 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); | 24 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
@@ -48,8 +47,7 @@ static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) | |||
48 | 47 | ||
49 | static int test__checkevent_raw(struct perf_evlist *evlist) | 48 | static int test__checkevent_raw(struct perf_evlist *evlist) |
50 | { | 49 | { |
51 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 50 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
52 | struct perf_evsel, node); | ||
53 | 51 | ||
54 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 52 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
55 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 53 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
@@ -59,8 +57,7 @@ static int test__checkevent_raw(struct perf_evlist *evlist) | |||
59 | 57 | ||
60 | static int test__checkevent_numeric(struct perf_evlist *evlist) | 58 | static int test__checkevent_numeric(struct perf_evlist *evlist) |
61 | { | 59 | { |
62 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 60 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
63 | struct perf_evsel, node); | ||
64 | 61 | ||
65 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 62 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
66 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | 63 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
@@ -70,8 +67,7 @@ static int test__checkevent_numeric(struct perf_evlist *evlist) | |||
70 | 67 | ||
71 | static int test__checkevent_symbolic_name(struct perf_evlist *evlist) | 68 | static int test__checkevent_symbolic_name(struct perf_evlist *evlist) |
72 | { | 69 | { |
73 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 70 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
74 | struct perf_evsel, node); | ||
75 | 71 | ||
76 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 72 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
77 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 73 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
@@ -82,8 +78,7 @@ static int test__checkevent_symbolic_name(struct perf_evlist *evlist) | |||
82 | 78 | ||
83 | static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) | 79 | static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) |
84 | { | 80 | { |
85 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 81 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
86 | struct perf_evsel, node); | ||
87 | 82 | ||
88 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 83 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
89 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 84 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
@@ -100,8 +95,7 @@ static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) | |||
100 | 95 | ||
101 | static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) | 96 | static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) |
102 | { | 97 | { |
103 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 98 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
104 | struct perf_evsel, node); | ||
105 | 99 | ||
106 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 100 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
107 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); | 101 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
@@ -112,8 +106,7 @@ static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) | |||
112 | 106 | ||
113 | static int test__checkevent_genhw(struct perf_evlist *evlist) | 107 | static int test__checkevent_genhw(struct perf_evlist *evlist) |
114 | { | 108 | { |
115 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 109 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
116 | struct perf_evsel, node); | ||
117 | 110 | ||
118 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 111 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
119 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); | 112 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); |
@@ -123,8 +116,7 @@ static int test__checkevent_genhw(struct perf_evlist *evlist) | |||
123 | 116 | ||
124 | static int test__checkevent_breakpoint(struct perf_evlist *evlist) | 117 | static int test__checkevent_breakpoint(struct perf_evlist *evlist) |
125 | { | 118 | { |
126 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 119 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
127 | struct perf_evsel, node); | ||
128 | 120 | ||
129 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 121 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
130 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | 122 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
@@ -138,8 +130,7 @@ static int test__checkevent_breakpoint(struct perf_evlist *evlist) | |||
138 | 130 | ||
139 | static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) | 131 | static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) |
140 | { | 132 | { |
141 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 133 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
142 | struct perf_evsel, node); | ||
143 | 134 | ||
144 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 135 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
145 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | 136 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); |
@@ -152,8 +143,7 @@ static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) | |||
152 | 143 | ||
153 | static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) | 144 | static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) |
154 | { | 145 | { |
155 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 146 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
156 | struct perf_evsel, node); | ||
157 | 147 | ||
158 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 148 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
159 | TEST_ASSERT_VAL("wrong type", | 149 | TEST_ASSERT_VAL("wrong type", |
@@ -168,8 +158,7 @@ static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) | |||
168 | 158 | ||
169 | static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) | 159 | static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) |
170 | { | 160 | { |
171 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 161 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
172 | struct perf_evsel, node); | ||
173 | 162 | ||
174 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 163 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
175 | TEST_ASSERT_VAL("wrong type", | 164 | TEST_ASSERT_VAL("wrong type", |
@@ -184,8 +173,7 @@ static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) | |||
184 | 173 | ||
185 | static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) | 174 | static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) |
186 | { | 175 | { |
187 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 176 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
188 | struct perf_evsel, node); | ||
189 | 177 | ||
190 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 178 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
191 | TEST_ASSERT_VAL("wrong type", | 179 | TEST_ASSERT_VAL("wrong type", |
@@ -200,8 +188,7 @@ static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) | |||
200 | 188 | ||
201 | static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) | 189 | static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) |
202 | { | 190 | { |
203 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 191 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
204 | struct perf_evsel, node); | ||
205 | 192 | ||
206 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 193 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
207 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | 194 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
@@ -232,8 +219,7 @@ test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) | |||
232 | 219 | ||
233 | static int test__checkevent_raw_modifier(struct perf_evlist *evlist) | 220 | static int test__checkevent_raw_modifier(struct perf_evlist *evlist) |
234 | { | 221 | { |
235 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 222 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
236 | struct perf_evsel, node); | ||
237 | 223 | ||
238 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 224 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
239 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | 225 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
@@ -245,8 +231,7 @@ static int test__checkevent_raw_modifier(struct perf_evlist *evlist) | |||
245 | 231 | ||
246 | static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) | 232 | static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) |
247 | { | 233 | { |
248 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 234 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
249 | struct perf_evsel, node); | ||
250 | 235 | ||
251 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 236 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
252 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | 237 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
@@ -258,8 +243,7 @@ static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) | |||
258 | 243 | ||
259 | static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) | 244 | static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) |
260 | { | 245 | { |
261 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 246 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
262 | struct perf_evsel, node); | ||
263 | 247 | ||
264 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 248 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
265 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | 249 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
@@ -271,8 +255,7 @@ static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) | |||
271 | 255 | ||
272 | static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) | 256 | static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) |
273 | { | 257 | { |
274 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 258 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
275 | struct perf_evsel, node); | ||
276 | 259 | ||
277 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | 260 | TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); |
278 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | 261 | TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); |
@@ -282,8 +265,7 @@ static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) | |||
282 | 265 | ||
283 | static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) | 266 | static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) |
284 | { | 267 | { |
285 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 268 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
286 | struct perf_evsel, node); | ||
287 | 269 | ||
288 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 270 | TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); |
289 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | 271 | TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); |
@@ -293,8 +275,7 @@ static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) | |||
293 | 275 | ||
294 | static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) | 276 | static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) |
295 | { | 277 | { |
296 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 278 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
297 | struct perf_evsel, node); | ||
298 | 279 | ||
299 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | 280 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
300 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | 281 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
@@ -306,8 +287,7 @@ static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) | |||
306 | 287 | ||
307 | static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) | 288 | static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) |
308 | { | 289 | { |
309 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 290 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
310 | struct perf_evsel, node); | ||
311 | 291 | ||
312 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 292 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
313 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | 293 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
@@ -319,8 +299,7 @@ static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) | |||
319 | 299 | ||
320 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) | 300 | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) |
321 | { | 301 | { |
322 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 302 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
323 | struct perf_evsel, node); | ||
324 | 303 | ||
325 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | 304 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
326 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | 305 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
@@ -334,8 +313,7 @@ static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) | |||
334 | 313 | ||
335 | static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) | 314 | static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) |
336 | { | 315 | { |
337 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 316 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
338 | struct perf_evsel, node); | ||
339 | 317 | ||
340 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 318 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
341 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | 319 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
@@ -349,8 +327,7 @@ static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) | |||
349 | 327 | ||
350 | static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) | 328 | static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) |
351 | { | 329 | { |
352 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 330 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
353 | struct perf_evsel, node); | ||
354 | 331 | ||
355 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 332 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
356 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | 333 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
@@ -364,8 +341,7 @@ static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) | |||
364 | 341 | ||
365 | static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) | 342 | static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) |
366 | { | 343 | { |
367 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 344 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
368 | struct perf_evsel, node); | ||
369 | 345 | ||
370 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | 346 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
371 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); | 347 | TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); |
@@ -379,8 +355,7 @@ static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) | |||
379 | 355 | ||
380 | static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) | 356 | static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) |
381 | { | 357 | { |
382 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 358 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
383 | struct perf_evsel, node); | ||
384 | 359 | ||
385 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 360 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
386 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); | 361 | TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); |
@@ -395,8 +370,7 @@ static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) | |||
395 | static int test__checkevent_pmu(struct perf_evlist *evlist) | 370 | static int test__checkevent_pmu(struct perf_evlist *evlist) |
396 | { | 371 | { |
397 | 372 | ||
398 | struct perf_evsel *evsel = list_entry(evlist->entries.next, | 373 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
399 | struct perf_evsel, node); | ||
400 | 374 | ||
401 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 375 | TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); |
402 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 376 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
@@ -410,12 +384,11 @@ static int test__checkevent_pmu(struct perf_evlist *evlist) | |||
410 | 384 | ||
411 | static int test__checkevent_list(struct perf_evlist *evlist) | 385 | static int test__checkevent_list(struct perf_evlist *evlist) |
412 | { | 386 | { |
413 | struct perf_evsel *evsel; | 387 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
414 | 388 | ||
415 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | 389 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
416 | 390 | ||
417 | /* r1 */ | 391 | /* r1 */ |
418 | evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
419 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 392 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
420 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | 393 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
421 | TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); | 394 | TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); |
@@ -426,7 +399,7 @@ static int test__checkevent_list(struct perf_evlist *evlist) | |||
426 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | 399 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
427 | 400 | ||
428 | /* syscalls:sys_enter_open:k */ | 401 | /* syscalls:sys_enter_open:k */ |
429 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 402 | evsel = perf_evsel__next(evsel); |
430 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); | 403 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
431 | TEST_ASSERT_VAL("wrong sample_type", | 404 | TEST_ASSERT_VAL("wrong sample_type", |
432 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | 405 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
@@ -437,7 +410,7 @@ static int test__checkevent_list(struct perf_evlist *evlist) | |||
437 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); | 410 | TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip); |
438 | 411 | ||
439 | /* 1:1:hp */ | 412 | /* 1:1:hp */ |
440 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 413 | evsel = perf_evsel__next(evsel); |
441 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | 414 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
442 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | 415 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
443 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); | 416 | TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); |
@@ -450,17 +423,16 @@ static int test__checkevent_list(struct perf_evlist *evlist) | |||
450 | 423 | ||
451 | static int test__checkevent_pmu_name(struct perf_evlist *evlist) | 424 | static int test__checkevent_pmu_name(struct perf_evlist *evlist) |
452 | { | 425 | { |
453 | struct perf_evsel *evsel; | 426 | struct perf_evsel *evsel = perf_evlist__first(evlist); |
454 | 427 | ||
455 | /* cpu/config=1,name=krava/u */ | 428 | /* cpu/config=1,name=krava/u */ |
456 | evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | ||
457 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 429 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
458 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 430 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
459 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | 431 | TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); |
460 | TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); | 432 | TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); |
461 | 433 | ||
462 | /* cpu/config=2/u" */ | 434 | /* cpu/config=2/u" */ |
463 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 435 | evsel = perf_evsel__next(evsel); |
464 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 436 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
465 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 437 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); |
466 | TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); | 438 | TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config); |
@@ -520,8 +492,7 @@ static int test__group1(struct perf_evlist *evlist) | |||
520 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 492 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
521 | 493 | ||
522 | /* instructions:k */ | 494 | /* instructions:k */ |
523 | evsel = leader = list_entry(evlist->entries.next, | 495 | evsel = leader = perf_evlist__first(evlist); |
524 | struct perf_evsel, node); | ||
525 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 496 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
526 | TEST_ASSERT_VAL("wrong config", | 497 | TEST_ASSERT_VAL("wrong config", |
527 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | 498 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
@@ -534,7 +505,7 @@ static int test__group1(struct perf_evlist *evlist) | |||
534 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); | 505 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
535 | 506 | ||
536 | /* cycles:upp */ | 507 | /* cycles:upp */ |
537 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 508 | evsel = perf_evsel__next(evsel); |
538 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 509 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
539 | TEST_ASSERT_VAL("wrong config", | 510 | TEST_ASSERT_VAL("wrong config", |
540 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 511 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -556,8 +527,7 @@ static int test__group2(struct perf_evlist *evlist) | |||
556 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | 527 | TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); |
557 | 528 | ||
558 | /* faults + :ku modifier */ | 529 | /* faults + :ku modifier */ |
559 | evsel = leader = list_entry(evlist->entries.next, | 530 | evsel = leader = perf_evlist__first(evlist); |
560 | struct perf_evsel, node); | ||
561 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); | 531 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); |
562 | TEST_ASSERT_VAL("wrong config", | 532 | TEST_ASSERT_VAL("wrong config", |
563 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); | 533 | PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); |
@@ -570,7 +540,7 @@ static int test__group2(struct perf_evlist *evlist) | |||
570 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); | 540 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
571 | 541 | ||
572 | /* cache-references + :u modifier */ | 542 | /* cache-references + :u modifier */ |
573 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 543 | evsel = perf_evsel__next(evsel); |
574 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 544 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
575 | TEST_ASSERT_VAL("wrong config", | 545 | TEST_ASSERT_VAL("wrong config", |
576 | PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); | 546 | PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config); |
@@ -583,7 +553,7 @@ static int test__group2(struct perf_evlist *evlist) | |||
583 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 553 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
584 | 554 | ||
585 | /* cycles:k */ | 555 | /* cycles:k */ |
586 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 556 | evsel = perf_evsel__next(evsel); |
587 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 557 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
588 | TEST_ASSERT_VAL("wrong config", | 558 | TEST_ASSERT_VAL("wrong config", |
589 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 559 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -605,8 +575,7 @@ static int test__group3(struct perf_evlist *evlist __used) | |||
605 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); | 575 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
606 | 576 | ||
607 | /* group1 syscalls:sys_enter_open:H */ | 577 | /* group1 syscalls:sys_enter_open:H */ |
608 | evsel = leader = list_entry(evlist->entries.next, | 578 | evsel = leader = perf_evlist__first(evlist); |
609 | struct perf_evsel, node); | ||
610 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); | 579 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); |
611 | TEST_ASSERT_VAL("wrong sample_type", | 580 | TEST_ASSERT_VAL("wrong sample_type", |
612 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | 581 | PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); |
@@ -622,7 +591,7 @@ static int test__group3(struct perf_evlist *evlist __used) | |||
622 | !strcmp(leader->group_name, "group1")); | 591 | !strcmp(leader->group_name, "group1")); |
623 | 592 | ||
624 | /* group1 cycles:kppp */ | 593 | /* group1 cycles:kppp */ |
625 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 594 | evsel = perf_evsel__next(evsel); |
626 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 595 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
627 | TEST_ASSERT_VAL("wrong config", | 596 | TEST_ASSERT_VAL("wrong config", |
628 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 597 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -636,7 +605,7 @@ static int test__group3(struct perf_evlist *evlist __used) | |||
636 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | 605 | TEST_ASSERT_VAL("wrong group name", !evsel->group_name); |
637 | 606 | ||
638 | /* group2 cycles + G modifier */ | 607 | /* group2 cycles + G modifier */ |
639 | evsel = leader = list_entry(evsel->node.next, struct perf_evsel, node); | 608 | evsel = leader = perf_evsel__next(evsel); |
640 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 609 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
641 | TEST_ASSERT_VAL("wrong config", | 610 | TEST_ASSERT_VAL("wrong config", |
642 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 611 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -651,7 +620,7 @@ static int test__group3(struct perf_evlist *evlist __used) | |||
651 | !strcmp(leader->group_name, "group2")); | 620 | !strcmp(leader->group_name, "group2")); |
652 | 621 | ||
653 | /* group2 1:3 + G modifier */ | 622 | /* group2 1:3 + G modifier */ |
654 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 623 | evsel = perf_evsel__next(evsel); |
655 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | 624 | TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); |
656 | TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); | 625 | TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config); |
657 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); | 626 | TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); |
@@ -663,7 +632,7 @@ static int test__group3(struct perf_evlist *evlist __used) | |||
663 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 632 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
664 | 633 | ||
665 | /* instructions:u */ | 634 | /* instructions:u */ |
666 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 635 | evsel = perf_evsel__next(evsel); |
667 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 636 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
668 | TEST_ASSERT_VAL("wrong config", | 637 | TEST_ASSERT_VAL("wrong config", |
669 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | 638 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
@@ -685,8 +654,7 @@ static int test__group4(struct perf_evlist *evlist __used) | |||
685 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 654 | TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); |
686 | 655 | ||
687 | /* cycles:u + p */ | 656 | /* cycles:u + p */ |
688 | evsel = leader = list_entry(evlist->entries.next, | 657 | evsel = leader = perf_evlist__first(evlist); |
689 | struct perf_evsel, node); | ||
690 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 658 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
691 | TEST_ASSERT_VAL("wrong config", | 659 | TEST_ASSERT_VAL("wrong config", |
692 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 660 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -700,7 +668,7 @@ static int test__group4(struct perf_evlist *evlist __used) | |||
700 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); | 668 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
701 | 669 | ||
702 | /* instructions:kp + p */ | 670 | /* instructions:kp + p */ |
703 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 671 | evsel = perf_evsel__next(evsel); |
704 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 672 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
705 | TEST_ASSERT_VAL("wrong config", | 673 | TEST_ASSERT_VAL("wrong config", |
706 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | 674 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
@@ -722,8 +690,7 @@ static int test__group5(struct perf_evlist *evlist __used) | |||
722 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); | 690 | TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); |
723 | 691 | ||
724 | /* cycles + G */ | 692 | /* cycles + G */ |
725 | evsel = leader = list_entry(evlist->entries.next, | 693 | evsel = leader = perf_evlist__first(evlist); |
726 | struct perf_evsel, node); | ||
727 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 694 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
728 | TEST_ASSERT_VAL("wrong config", | 695 | TEST_ASSERT_VAL("wrong config", |
729 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 696 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -737,7 +704,7 @@ static int test__group5(struct perf_evlist *evlist __used) | |||
737 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); | 704 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
738 | 705 | ||
739 | /* instructions + G */ | 706 | /* instructions + G */ |
740 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 707 | evsel = perf_evsel__next(evsel); |
741 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 708 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
742 | TEST_ASSERT_VAL("wrong config", | 709 | TEST_ASSERT_VAL("wrong config", |
743 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | 710 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
@@ -750,7 +717,7 @@ static int test__group5(struct perf_evlist *evlist __used) | |||
750 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 717 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
751 | 718 | ||
752 | /* cycles:G */ | 719 | /* cycles:G */ |
753 | evsel = leader = list_entry(evsel->node.next, struct perf_evsel, node); | 720 | evsel = leader = perf_evsel__next(evsel); |
754 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 721 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
755 | TEST_ASSERT_VAL("wrong config", | 722 | TEST_ASSERT_VAL("wrong config", |
756 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 723 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
@@ -764,7 +731,7 @@ static int test__group5(struct perf_evlist *evlist __used) | |||
764 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); | 731 | TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL); |
765 | 732 | ||
766 | /* instructions:G */ | 733 | /* instructions:G */ |
767 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 734 | evsel = perf_evsel__next(evsel); |
768 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 735 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
769 | TEST_ASSERT_VAL("wrong config", | 736 | TEST_ASSERT_VAL("wrong config", |
770 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | 737 | PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); |
@@ -777,7 +744,7 @@ static int test__group5(struct perf_evlist *evlist __used) | |||
777 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 744 | TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); |
778 | 745 | ||
779 | /* cycles */ | 746 | /* cycles */ |
780 | evsel = list_entry(evsel->node.next, struct perf_evsel, node); | 747 | evsel = perf_evsel__next(evsel); |
781 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 748 | TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); |
782 | TEST_ASSERT_VAL("wrong config", | 749 | TEST_ASSERT_VAL("wrong config", |
783 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); | 750 | PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 4393a6b65c51..925784a930a8 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -834,7 +834,7 @@ int parse_filter(const struct option *opt, const char *str, | |||
834 | struct perf_evsel *last = NULL; | 834 | struct perf_evsel *last = NULL; |
835 | 835 | ||
836 | if (evlist->nr_entries > 0) | 836 | if (evlist->nr_entries > 0) |
837 | last = list_entry(evlist->entries.prev, struct perf_evsel, node); | 837 | last = perf_evlist__last(evlist); |
838 | 838 | ||
839 | if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) { | 839 | if (last == NULL || last->attr.type != PERF_TYPE_TRACEPOINT) { |
840 | fprintf(stderr, | 840 | fprintf(stderr, |
diff --git a/tools/perf/util/top.c b/tools/perf/util/top.c index 7eeebcee291c..884dde9b9bc1 100644 --- a/tools/perf/util/top.c +++ b/tools/perf/util/top.c | |||
@@ -58,8 +58,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size) | |||
58 | } | 58 | } |
59 | 59 | ||
60 | if (top->evlist->nr_entries == 1) { | 60 | if (top->evlist->nr_entries == 1) { |
61 | struct perf_evsel *first; | 61 | struct perf_evsel *first = perf_evlist__first(top->evlist); |
62 | first = list_entry(top->evlist->entries.next, struct perf_evsel, node); | ||
63 | ret += SNPRINTF(bf + ret, size - ret, "%" PRIu64 "%s ", | 62 | ret += SNPRINTF(bf + ret, size - ret, "%" PRIu64 "%s ", |
64 | (uint64_t)first->attr.sample_period, | 63 | (uint64_t)first->attr.sample_period, |
65 | top->freq ? "Hz" : ""); | 64 | top->freq ? "Hz" : ""); |