perf evlist: Use the right prefix for 'struct evlist' 'find' methods
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 30 Nov 2020 12:48:07 +0000 (09:48 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 30 Nov 2020 12:48:07 +0000 (09:48 -0300)
perf_evlist__ is for 'struct perf_evlist' methods, in tools/lib/perf/,
go on completing this split.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-kmem.c
tools/perf/builtin-sched.c
tools/perf/builtin-trace.c
tools/perf/util/bpf-loader.c
tools/perf/util/evlist.c
tools/perf/util/evlist.h
tools/perf/util/evswitch.c
tools/perf/util/header.c

index a50dae2..0062445 100644 (file)
@@ -1960,18 +1960,15 @@ int cmd_kmem(int argc, const char **argv)
        ret = -1;
 
        if (kmem_slab) {
-               if (!perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                         "kmem:kmalloc")) {
+               if (!evlist__find_tracepoint_by_name(session->evlist, "kmem:kmalloc")) {
                        pr_err(errmsg, "slab", "slab");
                        goto out_delete;
                }
        }
 
        if (kmem_page) {
-               struct evsel *evsel;
+               struct evsel *evsel = evlist__find_tracepoint_by_name(session->evlist, "kmem:mm_page_alloc");
 
-               evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                            "kmem:mm_page_alloc");
                if (evsel == NULL) {
                        pr_err(errmsg, "page", "page");
                        goto out_delete;
index 0e16f9d..69c769b 100644 (file)
@@ -3036,8 +3036,7 @@ static int perf_sched__timehist(struct perf_sched *sched)
        setup_pager();
 
        /* prefer sched_waking if it is captured */
-       if (perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                 "sched:sched_waking"))
+       if (evlist__find_tracepoint_by_name(session->evlist, "sched:sched_waking"))
                handlers[1].handler = timehist_sched_wakeup_ignore;
 
        /* setup per-evsel handlers */
@@ -3045,8 +3044,7 @@ static int perf_sched__timehist(struct perf_sched *sched)
                goto out;
 
        /* sched_switch event at a minimum needs to exist */
-       if (!perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                 "sched:sched_switch")) {
+       if (!evlist__find_tracepoint_by_name(session->evlist, "sched:sched_switch")) {
                pr_err("No sched_switch events found. Have you run 'perf sched record'?\n");
                goto out;
        }
index 5638eae..6e47b19 100644 (file)
@@ -4227,12 +4227,10 @@ static int trace__replay(struct trace *trace)
        if (err)
                goto out;
 
-       evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                    "raw_syscalls:sys_enter");
+       evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_enter");
        /* older kernels have syscalls tp versus raw_syscalls */
        if (evsel == NULL)
-               evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                            "syscalls:sys_enter");
+               evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_enter");
 
        if (evsel &&
            (evsel__init_raw_syscall_tp(evsel, trace__sys_enter) < 0 ||
@@ -4241,11 +4239,9 @@ static int trace__replay(struct trace *trace)
                goto out;
        }
 
-       evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                    "raw_syscalls:sys_exit");
+       evsel = evlist__find_tracepoint_by_name(session->evlist, "raw_syscalls:sys_exit");
        if (evsel == NULL)
-               evsel = perf_evlist__find_tracepoint_by_name(session->evlist,
-                                                            "syscalls:sys_exit");
+               evsel = evlist__find_tracepoint_by_name(session->evlist, "syscalls:sys_exit");
        if (evsel &&
            (evsel__init_raw_syscall_tp(evsel, trace__sys_exit) < 0 ||
            perf_evsel__init_sc_tp_uint_field(evsel, ret))) {
@@ -4905,7 +4901,7 @@ int cmd_trace(int argc, const char **argv)
        if (evsel) {
                trace.syscalls.events.augmented = evsel;
 
-               evsel = perf_evlist__find_tracepoint_by_name(trace.evlist, "raw_syscalls:sys_enter");
+               evsel = evlist__find_tracepoint_by_name(trace.evlist, "raw_syscalls:sys_enter");
                if (evsel == NULL) {
                        pr_err("ERROR: raw_syscalls:sys_enter not found in the augmented BPF object\n");
                        goto out;
index 0374adc..9087f1b 100644 (file)
@@ -1058,12 +1058,11 @@ __bpf_map__config_event(struct bpf_map *map,
                        struct parse_events_term *term,
                        struct evlist *evlist)
 {
-       struct evsel *evsel;
        const struct bpf_map_def *def;
        struct bpf_map_op *op;
        const char *map_name = bpf_map__name(map);
+       struct evsel *evsel = evlist__find_evsel_by_str(evlist, term->val.str);
 
-       evsel = perf_evlist__find_evsel_by_str(evlist, term->val.str);
        if (!evsel) {
                pr_debug("Event (for '%s') '%s' doesn't exist\n",
                         map_name, term->val.str);
index 943262a..e6b2715 100644 (file)
@@ -191,13 +191,12 @@ void perf_evlist__splice_list_tail(struct evlist *evlist,
 int __evlist__set_tracepoints_handlers(struct evlist *evlist,
                                       const struct evsel_str_handler *assocs, size_t nr_assocs)
 {
-       struct evsel *evsel;
        size_t i;
        int err;
 
        for (i = 0; i < nr_assocs; i++) {
                // Adding a handler for an event not in this evlist, just ignore it.
-               evsel = perf_evlist__find_tracepoint_by_name(evlist, assocs[i].name);
+               struct evsel *evsel = evlist__find_tracepoint_by_name(evlist, assocs[i].name);
                if (evsel == NULL)
                        continue;
 
@@ -294,8 +293,7 @@ int __evlist__add_default_attrs(struct evlist *evlist, struct perf_event_attr *a
        return evlist__add_attrs(evlist, attrs, nr_attrs);
 }
 
-struct evsel *
-perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id)
+struct evsel *evlist__find_tracepoint_by_id(struct evlist *evlist, int id)
 {
        struct evsel *evsel;
 
@@ -308,9 +306,7 @@ perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id)
        return NULL;
 }
 
-struct evsel *
-perf_evlist__find_tracepoint_by_name(struct evlist *evlist,
-                                    const char *name)
+struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const char *name)
 {
        struct evsel *evsel;
 
@@ -1594,9 +1590,7 @@ void perf_evlist__set_tracking_event(struct evlist *evlist,
        tracking_evsel->tracking = true;
 }
 
-struct evsel *
-perf_evlist__find_evsel_by_str(struct evlist *evlist,
-                              const char *str)
+struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str)
 {
        struct evsel *evsel;
 
index c59a08c..aa9b3f9 100644 (file)
@@ -147,12 +147,8 @@ int evlist__append_tp_filter(struct evlist *evlist, const char *filter);
 int evlist__append_tp_filter_pid(struct evlist *evlist, pid_t pid);
 int evlist__append_tp_filter_pids(struct evlist *evlist, size_t npids, pid_t *pids);
 
-struct evsel *
-perf_evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
-
-struct evsel *
-perf_evlist__find_tracepoint_by_name(struct evlist *evlist,
-                                    const char *name);
+struct evsel *evlist__find_tracepoint_by_id(struct evlist *evlist, int id);
+struct evsel *evlist__find_tracepoint_by_name(struct evlist *evlist, const char *name);
 
 int evlist__add_pollfd(struct evlist *evlist, int fd);
 int evlist__filter_pollfd(struct evlist *evlist, short revents_and_mask);
@@ -338,8 +334,7 @@ void evlist__cpu_iter_start(struct evlist *evlist);
 bool evsel__cpu_iter_skip(struct evsel *ev, int cpu);
 bool evsel__cpu_iter_skip_no_inc(struct evsel *ev, int cpu);
 
-struct evsel *
-perf_evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
+struct evsel *evlist__find_evsel_by_str(struct evlist *evlist, const char *str);
 
 struct evsel *perf_evlist__event2evsel(struct evlist *evlist,
                                            union perf_event *event);
index 3ba72f7..40cb56a 100644 (file)
@@ -41,7 +41,7 @@ static int evswitch__fprintf_enoent(FILE *fp, const char *evtype, const char *ev
 int evswitch__init(struct evswitch *evswitch, struct evlist *evlist, FILE *fp)
 {
        if (evswitch->on_name) {
-               evswitch->on = perf_evlist__find_evsel_by_str(evlist, evswitch->on_name);
+               evswitch->on = evlist__find_evsel_by_str(evlist, evswitch->on_name);
                if (evswitch->on == NULL) {
                        evswitch__fprintf_enoent(fp, "on", evswitch->on_name);
                        return -ENOENT;
@@ -50,7 +50,7 @@ int evswitch__init(struct evswitch *evswitch, struct evlist *evlist, FILE *fp)
        }
 
        if (evswitch->off_name) {
-               evswitch->off = perf_evlist__find_evsel_by_str(evlist, evswitch->off_name);
+               evswitch->off = evlist__find_evsel_by_str(evlist, evswitch->off_name);
                if (evswitch->off == NULL) {
                        evswitch__fprintf_enoent(fp, "off", evswitch->off_name);
                        return -ENOENT;
index b65c8f7..64a3b83 100644 (file)
@@ -2263,8 +2263,7 @@ static int process_total_mem(struct feat_fd *ff, void *data __maybe_unused)
        return 0;
 }
 
-static struct evsel *
-perf_evlist__find_by_index(struct evlist *evlist, int idx)
+static struct evsel *evlist__find_by_index(struct evlist *evlist, int idx)
 {
        struct evsel *evsel;
 
@@ -2285,7 +2284,7 @@ perf_evlist__set_event_name(struct evlist *evlist,
        if (!event->name)
                return;
 
-       evsel = perf_evlist__find_by_index(evlist, event->idx);
+       evsel = evlist__find_by_index(evlist, event->idx);
        if (!evsel)
                return;