libperf: Add perf_evlist__first()/last() functions
authorJiri Olsa <jolsa@kernel.org>
Tue, 3 Sep 2019 08:39:52 +0000 (10:39 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 25 Sep 2019 12:51:48 +0000 (09:51 -0300)
Add perf_evlist__first()/last() functions to libperf, as internal
functions and rename perf's origins to evlist__first/last.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lore.kernel.org/lkml/20190913132355.21634-29-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
32 files changed:
tools/perf/arch/arm/util/cs-etm.c
tools/perf/arch/arm64/util/arm-spe.c
tools/perf/arch/x86/tests/intel-cqm.c
tools/perf/arch/x86/tests/perf-time-to-tsc.c
tools/perf/arch/x86/util/intel-bts.c
tools/perf/arch/x86/util/intel-pt.c
tools/perf/builtin-record.c
tools/perf/builtin-script.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/lib/include/internal/evlist.h
tools/perf/tests/code-reading.c
tools/perf/tests/event-times.c
tools/perf/tests/event_update.c
tools/perf/tests/evsel-roundtrip-name.c
tools/perf/tests/hists_cumulate.c
tools/perf/tests/hists_link.c
tools/perf/tests/hists_output.c
tools/perf/tests/keep-tracking.c
tools/perf/tests/parse-events.c
tools/perf/tests/perf-record.c
tools/perf/tests/switch-tracking.c
tools/perf/tests/task-exit.c
tools/perf/ui/browsers/hists.c
tools/perf/util/bpf-loader.c
tools/perf/util/evlist.c
tools/perf/util/evlist.h
tools/perf/util/jitdump.c
tools/perf/util/parse-events.c
tools/perf/util/record.c
tools/perf/util/sort.c
tools/perf/util/top.c

index 051e9066fb382ae17c890ad1203acdfc12cfa132..6654bcfc12247ecaba0af786bcfb5e755be21a98 100644 (file)
@@ -416,7 +416,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
                if (err)
                        goto out;
 
-               tracking_evsel = perf_evlist__last(evlist);
+               tracking_evsel = evlist__last(evlist);
                perf_evlist__set_tracking_event(evlist, tracking_evsel);
 
                tracking_evsel->core.attr.freq = 0;
index 9302c6566f532ac371cbd572b1cef85b1ff04309..745f2d50ee828ec3dcba7a4988b2a8a12a695aaa 100644 (file)
@@ -129,7 +129,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr,
        if (err)
                return err;
 
-       tracking_evsel = perf_evlist__last(evlist);
+       tracking_evsel = evlist__last(evlist);
        perf_evlist__set_tracking_event(evlist, tracking_evsel);
 
        tracking_evsel->core.attr.freq = 0;
index 111c0ab2e7b58a25465471eaa6c5121a0c7b7032..0329b9168faeb1df3d8b430d066226478dcee3b5 100644 (file)
@@ -62,9 +62,9 @@ int test__intel_cqm_count_nmi_context(struct test *test __maybe_unused, int subt
                goto out;
        }
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
        if (!evsel) {
-               pr_debug("perf_evlist__first failed\n");
+               pr_debug("evlist__first failed\n");
                goto out;
        }
 
index 10b7acebc0eb340f8b4716b50f34becf93e625a6..fa947952c16a16957704b8b4e9c3d03ce60e6f06 100644 (file)
@@ -83,7 +83,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
 
        perf_evlist__config(evlist, &opts, NULL);
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        evsel->core.attr.comm = 1;
        evsel->core.attr.disabled = 1;
index e81535c8e9c582ad60bd34bddb20c1bc63591bfd..e2c7095327db4c6f9ecc3103399da7e798ca053f 100644 (file)
@@ -231,7 +231,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
                if (err)
                        return err;
 
-               tracking_evsel = perf_evlist__last(evlist);
+               tracking_evsel = evlist__last(evlist);
 
                perf_evlist__set_tracking_event(evlist, tracking_evsel);
 
index 886b3ac60f23c7bbefa4877cf890ac2e2652f7fd..84a65524c418efb2be2c5f873aeb3f67f0a4dadd 100644 (file)
@@ -417,7 +417,7 @@ static int intel_pt_track_switches(struct evlist *evlist)
                return err;
        }
 
-       evsel = perf_evlist__last(evlist);
+       evsel = evlist__last(evlist);
 
        perf_evsel__set_sample_bit(evsel, CPU);
        perf_evsel__set_sample_bit(evsel, TIME);
@@ -717,7 +717,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
                                if (err)
                                        return err;
 
-                               switch_evsel = perf_evlist__last(evlist);
+                               switch_evsel = evlist__last(evlist);
 
                                switch_evsel->core.attr.freq = 0;
                                switch_evsel->core.attr.sample_period = 1;
@@ -775,7 +775,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
                if (err)
                        return err;
 
-               tracking_evsel = perf_evlist__last(evlist);
+               tracking_evsel = evlist__last(evlist);
 
                perf_evlist__set_tracking_event(evlist, tracking_evsel);
 
index 94997144547dd86f5bacfaf2f55a660a2f0b8fd9..48600c90cc7ea8e150b35a1375d771d67e26513e 100644 (file)
@@ -756,9 +756,9 @@ static int record__open(struct record *rec)
                if (perf_evlist__add_dummy(evlist))
                        return -ENOMEM;
 
-               pos = perf_evlist__first(evlist);
+               pos = evlist__first(evlist);
                pos->tracking = 0;
-               pos = perf_evlist__last(evlist);
+               pos = evlist__last(evlist);
                pos->tracking = 1;
                pos->core.attr.enable_on_exec = 1;
        }
index e7a49e2d7575519c2f861952d2c32e4a7956a2a9..22c1d114014c690937fe7e063d33cf20cf94b315 100644 (file)
@@ -2043,7 +2043,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
                return err;
 
        evlist = *pevlist;
-       evsel = perf_evlist__last(*pevlist);
+       evsel = evlist__last(*pevlist);
 
        if (!evsel->priv) {
                if (scr->per_event_dump) {
index 474b9860cfd40be3ecbc67d7ed3c79c0d4bf1b9a..73bf79053ae3996901d242fbdfa2df6195ab6800 100644 (file)
@@ -531,7 +531,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
                                prompt_integer(&counter, "Enter details event counter");
 
                                if (counter >= top->evlist->core.nr_entries) {
-                                       top->sym_evsel = perf_evlist__first(top->evlist);
+                                       top->sym_evsel = evlist__first(top->evlist);
                                        fprintf(stderr, "Sorry, no such event, using %s.\n", perf_evsel__name(top->sym_evsel));
                                        sleep(1);
                                        break;
@@ -540,7 +540,7 @@ static bool perf_top__handle_keypress(struct perf_top *top, int c)
                                        if (top->sym_evsel->idx == counter)
                                                break;
                        } else
-                               top->sym_evsel = perf_evlist__first(top->evlist);
+                               top->sym_evsel = evlist__first(top->evlist);
                        break;
                case 'f':
                        prompt_integer(&top->count_filter, "Enter display event count filter");
@@ -962,7 +962,7 @@ static int perf_top__overwrite_check(struct perf_top *top)
                /* has term for current event */
                if ((overwrite < 0) && (set >= 0)) {
                        /* if it's first event, set overwrite */
-                       if (evsel == perf_evlist__first(evlist))
+                       if (evsel == evlist__first(evlist))
                                overwrite = set;
                        else
                                return -1;
@@ -986,7 +986,7 @@ static int perf_top_overwrite_fallback(struct perf_top *top,
                return 0;
 
        /* only fall back when first event fails */
-       if (evsel != perf_evlist__first(evlist))
+       if (evsel != evlist__first(evlist))
                return 0;
 
        evlist__for_each_entry(evlist, counter)
@@ -1644,7 +1644,7 @@ int cmd_top(int argc, const char **argv)
                goto out_delete_evlist;
        }
 
-       top.sym_evsel = perf_evlist__first(top.evlist);
+       top.sym_evsel = evlist__first(top.evlist);
 
        if (!callchain_param.enabled) {
                symbol_conf.cumulate_callchain = false;
index 91c73c7472ba09fbba0cf78aaf3fe71098491fa3..97667287f5738573e0d7959f2cdf01b04a9fdaa6 100644 (file)
@@ -3427,7 +3427,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 
        trace->multiple_threads = perf_thread_map__pid(evlist->core.threads, 0) == -1 ||
                                  evlist->core.threads->nr > 1 ||
-                                 perf_evlist__first(evlist)->core.attr.inherit;
+                                 evlist__first(evlist)->core.attr.inherit;
 
        /*
         * Now that we already used evsel->core.attr to ask the kernel to setup the
index c5a06890fd6a9c6605bc0bdd00fd61d7b333c551..16ae6d6cfb3949121870fa9e6a0ff6cd8da8d587 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <linux/list.h>
 #include <api/fd/array.h>
+#include <internal/evsel.h>
 
 #define PERF_EVLIST__HLIST_BITS 8
 #define PERF_EVLIST__HLIST_SIZE (1 << PERF_EVLIST__HLIST_BITS)
@@ -55,4 +56,14 @@ struct perf_evlist {
 #define perf_evlist__for_each_entry_reverse(evlist, evsel) \
        __perf_evlist__for_each_entry_reverse(&(evlist)->entries, evsel)
 
+static inline struct perf_evsel *perf_evlist__first(struct perf_evlist *evlist)
+{
+       return list_entry(evlist->entries.next, struct perf_evsel, node);
+}
+
+static inline struct perf_evsel *perf_evlist__last(struct perf_evlist *evlist)
+{
+       return list_entry(evlist->entries.prev, struct perf_evsel, node);
+}
+
 #endif /* __LIBPERF_INTERNAL_EVLIST_H */
index 7dac69a375f93756c8ed6895a61c7f2e3db3c360..f5764a3890b96913fd097772fbc393dc6ee620bb 100644 (file)
@@ -652,7 +652,7 @@ static int do_test_code_reading(bool try_kcore)
 
                perf_evlist__config(evlist, &opts, NULL);
 
-               evsel = perf_evlist__first(evlist);
+               evsel = evlist__first(evlist);
 
                evsel->core.attr.comm = 1;
                evsel->core.attr.disabled = 1;
index 0228ba435a2a74f68e45443bf7045aa554f1f344..1ee8704e22849726dd30a0aa74642515fd07f059 100644 (file)
@@ -16,7 +16,7 @@
 
 static int attach__enable_on_exec(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__last(evlist);
+       struct evsel *evsel = evlist__last(evlist);
        struct target target = {
                .uid = UINT_MAX,
        };
@@ -58,7 +58,7 @@ static int detach__enable_on_exec(struct evlist *evlist)
 
 static int attach__current_disabled(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__last(evlist);
+       struct evsel *evsel = evlist__last(evlist);
        struct perf_thread_map *threads;
        int err;
 
@@ -84,7 +84,7 @@ static int attach__current_disabled(struct evlist *evlist)
 
 static int attach__current_enabled(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__last(evlist);
+       struct evsel *evsel = evlist__last(evlist);
        struct perf_thread_map *threads;
        int err;
 
@@ -104,14 +104,14 @@ static int attach__current_enabled(struct evlist *evlist)
 
 static int detach__disable(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__last(evlist);
+       struct evsel *evsel = evlist__last(evlist);
 
        return evsel__enable(evsel);
 }
 
 static int attach__cpu_disabled(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__last(evlist);
+       struct evsel *evsel = evlist__last(evlist);
        struct perf_cpu_map *cpus;
        int err;
 
@@ -140,7 +140,7 @@ static int attach__cpu_disabled(struct evlist *evlist)
 
 static int attach__cpu_enabled(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__last(evlist);
+       struct evsel *evsel = evlist__last(evlist);
        struct perf_cpu_map *cpus;
        int err;
 
@@ -180,7 +180,7 @@ static int test_times(int (attach)(struct evlist *),
                goto out_err;
        }
 
-       evsel = perf_evlist__last(evlist);
+       evsel = evlist__last(evlist);
        evsel->core.attr.read_format |=
                PERF_FORMAT_TOTAL_TIME_ENABLED |
                PERF_FORMAT_TOTAL_TIME_RUNNING;
index cf4f90170f9015d2a717f9e3213d32ff5b70e033..cd6cae8e51376d62c80c727700efdf9f125816f4 100644 (file)
@@ -92,7 +92,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
        evlist = perf_evlist__new_default();
        TEST_ASSERT_VAL("failed to get evlist", evlist);
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("failed to allocate ids",
                        !perf_evsel__alloc_id(&evsel->core, 1, 1));
index 5330f106a6ee440a20271f49228fb6005804e2af..956205bf932651949b2793869c35199c4de8a479 100644 (file)
@@ -34,7 +34,7 @@ static int perf_evsel__roundtrip_cache_name_test(void)
        }
 
        idx = 0;
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        for (type = 0; type < PERF_COUNT_HW_CACHE_MAX; type++) {
                for (op = 0; op < PERF_COUNT_HW_CACHE_OP_MAX; op++) {
index fa55b7bad3af28433d7ce475d73910170cb65728..6367c8f6ca22f80cd340b0668c2a5d1fe476cbd0 100644 (file)
@@ -721,7 +721,7 @@ int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_u
        if (verbose > 1)
                machine__fprintf(machine, stderr);
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        for (i = 0; i < ARRAY_SIZE(testcases); i++) {
                err = testcases[i](evsel, machine);
index 1a3bdc0a2d142a9d2b73d629d1d01a0bb1d6a7c1..a024d3f3a4123dd0167218f86b2cbe1423e7a931 100644 (file)
@@ -311,8 +311,8 @@ int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unuse
                        print_hists_in(hists);
        }
 
-       first = perf_evlist__first(evlist);
-       evsel = perf_evlist__last(evlist);
+       first = evlist__first(evlist);
+       evsel = evlist__last(evlist);
 
        first_hists = evsel__hists(first);
        hists = evsel__hists(evsel);
index 3f6dfa21226062498e494f76fd39487db022bf3b..38f804ff645275e4d8a2b809b5ede70963e7c0ad 100644 (file)
@@ -608,7 +608,7 @@ int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unu
        if (verbose > 1)
                machine__fprintf(machine, stderr);
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        for (i = 0; i < ARRAY_SIZE(testcases); i++) {
                err = testcases[i](evsel, machine);
index bd4ae8e5cd5da3dd614190885beb88ac0efff6f8..92c7d591bcacca3d717db7b48b0a8cfbde75c0c1 100644 (file)
@@ -93,7 +93,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un
 
        perf_evlist__config(evlist, &opts, NULL);
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        evsel->core.attr.comm = 1;
        evsel->core.attr.disabled = 1;
@@ -132,7 +132,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un
 
        evlist__enable(evlist);
 
-       evsel = perf_evlist__last(evlist);
+       evsel = evlist__last(evlist);
 
        CHECK__(evsel__disable(evsel));
 
index c25c8e7b41e5476a5ae3b708d6b7be80aa95abe9..25e0ed2eedfccc47387e757e3c01b16ebdc6b8bc 100644 (file)
@@ -46,7 +46,7 @@ static bool kvm_s390_create_vm_valid(void)
 
 static int test__checkevent_tracepoint(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
@@ -77,7 +77,7 @@ static int test__checkevent_tracepoint_multi(struct evlist *evlist)
 
 static int test__checkevent_raw(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
@@ -87,7 +87,7 @@ static int test__checkevent_raw(struct evlist *evlist)
 
 static int test__checkevent_numeric(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
@@ -97,7 +97,7 @@ static int test__checkevent_numeric(struct evlist *evlist)
 
 static int test__checkevent_symbolic_name(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -108,7 +108,7 @@ static int test__checkevent_symbolic_name(struct evlist *evlist)
 
 static int test__checkevent_symbolic_name_config(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -129,7 +129,7 @@ static int test__checkevent_symbolic_name_config(struct evlist *evlist)
 
 static int test__checkevent_symbolic_alias(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
@@ -140,7 +140,7 @@ static int test__checkevent_symbolic_alias(struct evlist *evlist)
 
 static int test__checkevent_genhw(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->core.attr.type);
@@ -150,7 +150,7 @@ static int test__checkevent_genhw(struct evlist *evlist)
 
 static int test__checkevent_breakpoint(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
@@ -164,7 +164,7 @@ static int test__checkevent_breakpoint(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_x(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
@@ -177,7 +177,7 @@ static int test__checkevent_breakpoint_x(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_r(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type",
@@ -192,7 +192,7 @@ static int test__checkevent_breakpoint_r(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_w(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type",
@@ -207,7 +207,7 @@ static int test__checkevent_breakpoint_w(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_rw(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type",
@@ -222,7 +222,7 @@ static int test__checkevent_breakpoint_rw(struct evlist *evlist)
 
 static int test__checkevent_tracepoint_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
@@ -253,7 +253,7 @@ test__checkevent_tracepoint_multi_modifier(struct evlist *evlist)
 
 static int test__checkevent_raw_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
@@ -265,7 +265,7 @@ static int test__checkevent_raw_modifier(struct evlist *evlist)
 
 static int test__checkevent_numeric_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -277,7 +277,7 @@ static int test__checkevent_numeric_modifier(struct evlist *evlist)
 
 static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -289,7 +289,7 @@ static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
 
 static int test__checkevent_exclude_host_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
        TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
@@ -299,7 +299,7 @@ static int test__checkevent_exclude_host_modifier(struct evlist *evlist)
 
 static int test__checkevent_exclude_guest_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
        TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
@@ -309,7 +309,7 @@ static int test__checkevent_exclude_guest_modifier(struct evlist *evlist)
 
 static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -321,7 +321,7 @@ static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist)
 
 static int test__checkevent_genhw_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
@@ -333,7 +333,7 @@ static int test__checkevent_genhw_modifier(struct evlist *evlist)
 
 static int test__checkevent_exclude_idle_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
        TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
@@ -348,7 +348,7 @@ static int test__checkevent_exclude_idle_modifier(struct evlist *evlist)
 
 static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
        TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
@@ -363,7 +363,7 @@ static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
 
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
@@ -378,7 +378,7 @@ static int test__checkevent_breakpoint_modifier(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
@@ -392,7 +392,7 @@ static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -406,7 +406,7 @@ static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -420,7 +420,7 @@ static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
@@ -435,7 +435,7 @@ static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist)
 static int test__checkevent_pmu(struct evlist *evlist)
 {
 
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
@@ -453,7 +453,7 @@ static int test__checkevent_pmu(struct evlist *evlist)
 
 static int test__checkevent_list(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
 
@@ -492,7 +492,7 @@ static int test__checkevent_list(struct evlist *evlist)
 
 static int test__checkevent_pmu_name(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        /* cpu/config=1,name=krava/u */
        TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
@@ -513,7 +513,7 @@ static int test__checkevent_pmu_name(struct evlist *evlist)
 
 static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        /* cpu/config=1,call-graph=fp,time,period=100000/ */
        TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
@@ -546,7 +546,7 @@ static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
 
 static int test__checkevent_pmu_events(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
@@ -564,7 +564,7 @@ static int test__checkevent_pmu_events(struct evlist *evlist)
 
 static int test__checkevent_pmu_events_mix(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        /* pmu-event:u */
        TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
@@ -642,7 +642,7 @@ static int test__group1(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* instructions:k */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
@@ -684,7 +684,7 @@ static int test__group2(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* faults + :ku modifier */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
@@ -739,7 +739,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)
        TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
 
        /* group1 syscalls:sys_enter_openat:H */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong sample_type",
                PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
@@ -831,7 +831,7 @@ static int test__group4(struct evlist *evlist __maybe_unused)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles:u + p */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -875,7 +875,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)
        TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
 
        /* cycles + G */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -961,7 +961,7 @@ static int test__group_gh1(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles + :H group modifier */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -1001,7 +1001,7 @@ static int test__group_gh2(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles + :G group modifier */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -1041,7 +1041,7 @@ static int test__group_gh3(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles:G + :u group modifier */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -1081,7 +1081,7 @@ static int test__group_gh4(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
 
        /* cycles:G + :uG group modifier */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -1120,7 +1120,7 @@ static int test__leader_sample1(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
 
        /* cycles - sampling group leader */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -1173,7 +1173,7 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused)
        TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
 
        /* instructions - sampling group leader */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_INSTRUCTIONS == evsel->core.attr.config);
@@ -1207,7 +1207,7 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused)
 
 static int test__checkevent_pinned_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -1225,7 +1225,7 @@ static int test__pinned_group(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries);
 
        /* cycles - group leader */
-       evsel = leader = perf_evlist__first(evlist);
+       evsel = leader = evlist__first(evlist);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
        TEST_ASSERT_VAL("wrong config",
                        PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config);
@@ -1251,7 +1251,7 @@ static int test__pinned_group(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_len(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
@@ -1266,7 +1266,7 @@ static int test__checkevent_breakpoint_len(struct evlist *evlist)
 
 static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
@@ -1282,7 +1282,7 @@ static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
 static int
 test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -1294,7 +1294,7 @@ test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
 
 static int test__checkevent_precise_max_modifier(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
        TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
@@ -1305,7 +1305,7 @@ static int test__checkevent_precise_max_modifier(struct evlist *evlist)
 
 static int test__checkevent_config_symbol(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
        return 0;
@@ -1313,7 +1313,7 @@ static int test__checkevent_config_symbol(struct evlist *evlist)
 
 static int test__checkevent_config_raw(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
        return 0;
@@ -1321,7 +1321,7 @@ static int test__checkevent_config_raw(struct evlist *evlist)
 
 static int test__checkevent_config_num(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
        return 0;
@@ -1329,7 +1329,7 @@ static int test__checkevent_config_num(struct evlist *evlist)
 
 static int test__checkevent_config_cache(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
        return 0;
@@ -1342,7 +1342,7 @@ static bool test__intel_pt_valid(void)
 
 static int test__intel_pt(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0);
        return 0;
@@ -1350,7 +1350,7 @@ static int test__intel_pt(struct evlist *evlist)
 
 static int test__checkevent_complex_name(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0);
        return 0;
@@ -1358,7 +1358,7 @@ static int test__checkevent_complex_name(struct evlist *evlist)
 
 static int test__sym_event_slash(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
        TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
@@ -1368,7 +1368,7 @@ static int test__sym_event_slash(struct evlist *evlist)
 
 static int test__sym_event_dc(struct evlist *evlist)
 {
-       struct evsel *evsel = perf_evlist__first(evlist);
+       struct evsel *evsel = evlist__first(evlist);
 
        TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
        TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == PERF_COUNT_HW_CPU_CYCLES);
index 199a66444e6050c332a8f2bf7328f46cffd67c77..401e8d11427b27baa4db290cd1072716dd26f56e 100644 (file)
@@ -104,7 +104,7 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
        /*
         * Config the evsels, setting attr->comm on the first one, etc.
         */
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
        perf_evsel__set_sample_bit(evsel, CPU);
        perf_evsel__set_sample_bit(evsel, TID);
        perf_evsel__set_sample_bit(evsel, TIME);
index 30a70db6473d2cb5cae40abd6c692f814453534c..ffa592e0020eeda9963a27ab04f0c9c68e4144fe 100644 (file)
@@ -367,7 +367,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
                goto out_err;
        }
 
-       cpu_clocks_evsel = perf_evlist__last(evlist);
+       cpu_clocks_evsel = evlist__last(evlist);
 
        /* Second event */
        err = parse_events(evlist, "cycles:u", NULL);
@@ -376,7 +376,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
                goto out_err;
        }
 
-       cycles_evsel = perf_evlist__last(evlist);
+       cycles_evsel = evlist__last(evlist);
 
        /* Third event */
        if (!perf_evlist__can_select_event(evlist, sched_switch)) {
@@ -391,7 +391,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
                goto out_err;
        }
 
-       switch_evsel = perf_evlist__last(evlist);
+       switch_evsel = evlist__last(evlist);
 
        perf_evsel__set_sample_bit(switch_evsel, CPU);
        perf_evsel__set_sample_bit(switch_evsel, TIME);
@@ -401,12 +401,12 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
        switch_evsel->immediate = true;
 
        /* Test moving an event to the front */
-       if (cycles_evsel == perf_evlist__first(evlist)) {
+       if (cycles_evsel == evlist__first(evlist)) {
                pr_debug("cycles event already at front");
                goto out_err;
        }
        perf_evlist__to_front(evlist, cycles_evsel);
-       if (cycles_evsel != perf_evlist__first(evlist)) {
+       if (cycles_evsel != evlist__first(evlist)) {
                pr_debug("Failed to move cycles event to front");
                goto out_err;
        }
@@ -421,7 +421,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
                goto out_err;
        }
 
-       tracking_evsel = perf_evlist__last(evlist);
+       tracking_evsel = evlist__last(evlist);
 
        perf_evlist__set_tracking_event(evlist, tracking_evsel);
 
@@ -434,7 +434,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
        perf_evlist__config(evlist, &opts, NULL);
 
        /* Check moved event is still at the front */
-       if (cycles_evsel != perf_evlist__first(evlist)) {
+       if (cycles_evsel != evlist__first(evlist)) {
                pr_debug("Front event no longer at front");
                goto out_err;
        }
index 7fc39af48a7638d0baeba7f1481acc28132b415b..24565f83e07d2403a6531dace7d916887c28a84f 100644 (file)
@@ -88,7 +88,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
                goto out_delete_evlist;
        }
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
        evsel->core.attr.task = 1;
 #ifdef __s390x__
        evsel->core.attr.sample_freq = 1000000;
index 589168ca9f62ca7a6dea8fb213a8d857e401c3f5..7a7187e069b48adf05ef5498bcaf306b8e6f8119 100644 (file)
@@ -3319,13 +3319,13 @@ browse_hists:
                        switch (key) {
                        case K_TAB:
                                if (pos->core.node.next == &evlist->core.entries)
-                                       pos = perf_evlist__first(evlist);
+                                       pos = evlist__first(evlist);
                                else
                                        pos = perf_evsel__next(pos);
                                goto browse_hists;
                        case K_UNTAB:
                                if (pos->core.node.prev == &evlist->core.entries)
-                                       pos = perf_evlist__last(evlist);
+                                       pos = evlist__last(evlist);
                                else
                                        pos = perf_evsel__prev(pos);
                                goto browse_hists;
@@ -3417,7 +3417,7 @@ int perf_evlist__tui_browse_hists(struct evlist *evlist, const char *help,
 
 single_entry:
        if (nr_entries == 1) {
-               struct evsel *first = perf_evlist__first(evlist);
+               struct evsel *first = evlist__first(evlist);
 
                return perf_evsel__hists_browse(first, nr_entries, help,
                                                false, hbt, min_pcnt,
index 37283e8653525da561a0d9d76913cb3e9f32a0c7..10c187b8b8ead6301175edd860881e6f44f52eb9 100644 (file)
@@ -1568,7 +1568,7 @@ struct evsel *bpf__setup_output_event(struct evlist *evlist, const char *name)
                        return ERR_PTR(-err);
                }
 
-               evsel = perf_evlist__last(evlist);
+               evsel = evlist__last(evlist);
        }
 
        bpf__for_each_map_named(map, obj, tmp, name) {
index 559db38594a800f8ec6d376192329e245dd10c84..e8f0357b153200a4ab190fd0915a16d033688235 100644 (file)
@@ -105,7 +105,7 @@ struct evlist *perf_evlist__new_dummy(void)
  */
 void perf_evlist__set_id_pos(struct evlist *evlist)
 {
-       struct evsel *first = perf_evlist__first(evlist);
+       struct evsel *first = evlist__first(evlist);
 
        evlist->id_pos = first->id_pos;
        evlist->is_pos = first->is_pos;
@@ -559,14 +559,14 @@ struct evsel *perf_evlist__id2evsel(struct evlist *evlist, u64 id)
        struct perf_sample_id *sid;
 
        if (evlist->core.nr_entries == 1 || !id)
-               return perf_evlist__first(evlist);
+               return evlist__first(evlist);
 
        sid = perf_evlist__id2sid(evlist, id);
        if (sid)
                return container_of(sid->evsel, struct evsel, core);
 
        if (!perf_evlist__sample_id_all(evlist))
-               return perf_evlist__first(evlist);
+               return evlist__first(evlist);
 
        return NULL;
 }
@@ -610,7 +610,7 @@ static int perf_evlist__event2id(struct evlist *evlist,
 struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
                                            union perf_event *event)
 {
-       struct evsel *first = perf_evlist__first(evlist);
+       struct evsel *first = evlist__first(evlist);
        struct hlist_head *head;
        struct perf_sample_id *sid;
        int hash;
@@ -1222,7 +1222,7 @@ u64 perf_evlist__combined_branch_type(struct evlist *evlist)
 
 bool perf_evlist__valid_read_format(struct evlist *evlist)
 {
-       struct evsel *first = perf_evlist__first(evlist), *pos = first;
+       struct evsel *first = evlist__first(evlist), *pos = first;
        u64 read_format = first->core.attr.read_format;
        u64 sample_type = first->core.attr.sample_type;
 
@@ -1242,13 +1242,13 @@ bool perf_evlist__valid_read_format(struct evlist *evlist)
 
 u64 perf_evlist__read_format(struct evlist *evlist)
 {
-       struct evsel *first = perf_evlist__first(evlist);
+       struct evsel *first = evlist__first(evlist);
        return first->core.attr.read_format;
 }
 
 u16 perf_evlist__id_hdr_size(struct evlist *evlist)
 {
-       struct evsel *first = perf_evlist__first(evlist);
+       struct evsel *first = evlist__first(evlist);
        struct perf_sample *data;
        u64 sample_type;
        u16 size = 0;
@@ -1281,7 +1281,7 @@ out:
 
 bool perf_evlist__valid_sample_id_all(struct evlist *evlist)
 {
-       struct evsel *first = perf_evlist__first(evlist), *pos = first;
+       struct evsel *first = evlist__first(evlist), *pos = first;
 
        evlist__for_each_entry_continue(evlist, pos) {
                if (first->core.attr.sample_id_all != pos->core.attr.sample_id_all)
@@ -1293,7 +1293,7 @@ bool perf_evlist__valid_sample_id_all(struct evlist *evlist)
 
 bool perf_evlist__sample_id_all(struct evlist *evlist)
 {
-       struct evsel *first = perf_evlist__first(evlist);
+       struct evsel *first = evlist__first(evlist);
        return first->core.attr.sample_id_all;
 }
 
@@ -1568,7 +1568,7 @@ int perf_evlist__strerror_open(struct evlist *evlist,
                                    "Hint:\tThe current value is %d.", value);
                break;
        case EINVAL: {
-               struct evsel *first = perf_evlist__first(evlist);
+               struct evsel *first = evlist__first(evlist);
                int max_freq;
 
                if (sysctl__read_int("kernel/perf_event_max_sample_rate", &max_freq) < 0)
@@ -1630,7 +1630,7 @@ void perf_evlist__to_front(struct evlist *evlist,
        struct evsel *evsel, *n;
        LIST_HEAD(move);
 
-       if (move_evsel == perf_evlist__first(evlist))
+       if (move_evsel == evlist__first(evlist))
                return;
 
        evlist__for_each_entry_safe(evlist, n, evsel) {
@@ -1751,7 +1751,7 @@ bool perf_evlist__exclude_kernel(struct evlist *evlist)
 void perf_evlist__force_leader(struct evlist *evlist)
 {
        if (!evlist->nr_groups) {
-               struct evsel *leader = perf_evlist__first(evlist);
+               struct evsel *leader = evlist__first(evlist);
 
                perf_evlist__set_leader(evlist);
                leader->forced_leader = true;
index ad9c0ba57a919c311f24b7c44163a3370e3b64e4..6529ad2a9d97c7d0c5e98d7d94839d435f8f9dbe 100644 (file)
@@ -9,6 +9,7 @@
 #include <api/fd/array.h>
 #include <stdio.h>
 #include <internal/evlist.h>
+#include <internal/evsel.h>
 #include "events_stats.h"
 #include "evsel.h"
 #include <pthread.h>
@@ -242,14 +243,18 @@ static inline bool perf_evlist__empty(struct evlist *evlist)
        return list_empty(&evlist->core.entries);
 }
 
-static inline struct evsel *perf_evlist__first(struct evlist *evlist)
+static inline struct evsel *evlist__first(struct evlist *evlist)
 {
-       return list_entry(evlist->core.entries.next, struct evsel, core.node);
+       struct perf_evsel *evsel = perf_evlist__first(&evlist->core);
+
+       return container_of(evsel, struct evsel, core);
 }
 
-static inline struct evsel *perf_evlist__last(struct evlist *evlist)
+static inline struct evsel *evlist__last(struct evlist *evlist)
 {
-       return list_entry(evlist->core.entries.prev, struct evsel, core.node);
+       struct perf_evsel *evsel = perf_evlist__last(&evlist->core);
+
+       return container_of(evsel, struct evsel, core);
 }
 
 size_t perf_evlist__fprintf(struct evlist *evlist, FILE *fp);
index 9f9c6c6a2fd3be32a13784d22899b605673b2bef..1bdf4c6ea3e5050398a526447019364dd6f5c16f 100644 (file)
@@ -777,7 +777,7 @@ jit_process(struct perf_session *session,
         * track sample_type to compute id_all layout
         * perf sets the same sample type to all events as of now
         */
-       first = perf_evlist__first(session->evlist);
+       first = evlist__first(session->evlist);
        jd.sample_type = first->core.attr.sample_type;
 
        *nbytes = 0;
index d7aebe9b005d6d58e8c17ed1945eafb40421adab..d69ff746cda5e3c143bd1e73e90c2aebebd121ca 100644 (file)
@@ -1936,7 +1936,7 @@ int parse_events(struct evlist *evlist, const char *str,
 
                perf_evlist__splice_list_tail(evlist, &parse_state.list);
                evlist->nr_groups += parse_state.nr_groups;
-               last = perf_evlist__last(evlist);
+               last = evlist__last(evlist);
                last->cmdline_group_boundary = true;
 
                return 0;
@@ -2050,7 +2050,7 @@ foreach_evsel_in_last_glob(struct evlist *evlist,
         * So no need to WARN here, let *func do this.
         */
        if (evlist->core.nr_entries > 0)
-               last = perf_evlist__last(evlist);
+               last = evlist__last(evlist);
 
        do {
                err = (*func)(last, arg);
index 8a015fc0aba0a7893b73f84dc865c548356f86ed..8579505c29a4df774e64bd7f883ab534eda5b8d7 100644 (file)
@@ -30,7 +30,7 @@ static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str)
        if (parse_events(evlist, str, NULL))
                goto out_delete;
 
-       evsel = perf_evlist__first(evlist);
+       evsel = evlist__first(evlist);
 
        while (1) {
                fd = sys_perf_event_open(&evsel->core.attr, pid, cpu, -1, flags);
@@ -171,7 +171,7 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,
                use_sample_identifier = perf_can_sample_identifier();
                sample_id = true;
        } else if (evlist->core.nr_entries > 1) {
-               struct evsel *first = perf_evlist__first(evlist);
+               struct evsel *first = evlist__first(evlist);
 
                evlist__for_each_entry(evlist, evsel) {
                        if (evsel->core.attr.sample_type == first->core.attr.sample_type)
@@ -276,7 +276,7 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str)
        if (err)
                goto out_delete;
 
-       evsel = perf_evlist__last(temp_evlist);
+       evsel = evlist__last(temp_evlist);
 
        if (!evlist || perf_cpu_map__empty(evlist->core.cpus)) {
                struct perf_cpu_map *cpus = perf_cpu_map__new(NULL);
index a2308eb77681771d36aa7c8ec22d522745fa6336..43d1d410854a3c661e495587164f81e05443fc3d 100644 (file)
@@ -2329,7 +2329,7 @@ static struct evsel *find_evsel(struct evlist *evlist, char *event_name)
                if (nr > evlist->core.nr_entries)
                        return NULL;
 
-               evsel = perf_evlist__first(evlist);
+               evsel = evlist__first(evlist);
                while (--nr > 0)
                        evsel = perf_evsel__next(evsel);
 
index ef96e3dd6902a701dd881ec4926143dd81b2600d..3dce2de9d005daafd0ceecbacacbb40ce7178676 100644 (file)
@@ -71,7 +71,7 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)
        }
 
        if (top->evlist->core.nr_entries == 1) {
-               struct evsel *first = perf_evlist__first(top->evlist);
+               struct evsel *first = evlist__first(top->evlist);
                ret += SNPRINTF(bf + ret, size - ret, "%" PRIu64 "%s ",
                                (uint64_t)first->core.attr.sample_period,
                                opts->freq ? "Hz" : "");