Commit cd102d70 authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

perf bpf: Rename bpf__foreach_tev() to bpf__foreach_event()

Following commit will allow BPF script attach to tracepoints.
bpf__foreach_tev() will iterate over all events, not only kprobes.
Rename it to bpf__foreach_event().

Since only group and event are used by caller, there's no need to pass
full 'struct probe_trace_event' to bpf_prog_iter_callback_t. Pass only
these two strings. After this patch bpf_prog_iter_callback_t natually
support tracepoints.
Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1468406646-21642-5-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 8c619d6a
......@@ -693,7 +693,7 @@ int bpf__load(struct bpf_object *obj)
return 0;
}
int bpf__foreach_tev(struct bpf_object *obj,
int bpf__foreach_event(struct bpf_object *obj,
bpf_prog_iter_callback_t func,
void *arg)
{
......@@ -728,7 +728,7 @@ int bpf__foreach_tev(struct bpf_object *obj,
return fd;
}
err = (*func)(tev, fd, arg);
err = (*func)(tev->group, tev->event, fd, arg);
if (err) {
pr_debug("bpf: call back failed, stop iterate\n");
return err;
......
......@@ -46,7 +46,7 @@ struct bpf_object;
struct parse_events_term;
#define PERF_BPF_PROBE_GROUP "perf_bpf_probe"
typedef int (*bpf_prog_iter_callback_t)(struct probe_trace_event *tev,
typedef int (*bpf_prog_iter_callback_t)(const char *group, const char *event,
int fd, void *arg);
#ifdef HAVE_LIBBPF_SUPPORT
......@@ -67,7 +67,7 @@ int bpf__strerror_probe(struct bpf_object *obj, int err,
int bpf__load(struct bpf_object *obj);
int bpf__strerror_load(struct bpf_object *obj, int err,
char *buf, size_t size);
int bpf__foreach_tev(struct bpf_object *obj,
int bpf__foreach_event(struct bpf_object *obj,
bpf_prog_iter_callback_t func, void *arg);
int bpf__config_obj(struct bpf_object *obj, struct parse_events_term *term,
......@@ -107,7 +107,7 @@ static inline int bpf__unprobe(struct bpf_object *obj __maybe_unused) { return 0
static inline int bpf__load(struct bpf_object *obj __maybe_unused) { return 0; }
static inline int
bpf__foreach_tev(struct bpf_object *obj __maybe_unused,
bpf__foreach_event(struct bpf_object *obj __maybe_unused,
bpf_prog_iter_callback_t func __maybe_unused,
void *arg __maybe_unused)
{
......
......@@ -584,7 +584,7 @@ struct __add_bpf_event_param {
struct list_head *head_config;
};
static int add_bpf_event(struct probe_trace_event *tev, int fd,
static int add_bpf_event(const char *group, const char *event, int fd,
void *_param)
{
LIST_HEAD(new_evsels);
......@@ -595,27 +595,27 @@ static int add_bpf_event(struct probe_trace_event *tev, int fd,
int err;
pr_debug("add bpf event %s:%s and attach bpf program %d\n",
tev->group, tev->event, fd);
group, event, fd);
err = parse_events_add_tracepoint(&new_evsels, &evlist->idx, tev->group,
tev->event, evlist->error,
err = parse_events_add_tracepoint(&new_evsels, &evlist->idx, group,
event, evlist->error,
param->head_config);
if (err) {
struct perf_evsel *evsel, *tmp;
pr_debug("Failed to add BPF event %s:%s\n",
tev->group, tev->event);
group, event);
list_for_each_entry_safe(evsel, tmp, &new_evsels, node) {
list_del(&evsel->node);
perf_evsel__delete(evsel);
}
return err;
}
pr_debug("adding %s:%s\n", tev->group, tev->event);
pr_debug("adding %s:%s\n", group, event);
list_for_each_entry(pos, &new_evsels, node) {
pr_debug("adding %s:%s to %p\n",
tev->group, tev->event, pos);
group, event, pos);
pos->bpf_fd = fd;
}
list_splice(&new_evsels, list);
......@@ -661,7 +661,7 @@ int parse_events_load_bpf_obj(struct parse_events_evlist *data,
goto errout;
}
err = bpf__foreach_tev(obj, add_bpf_event, &param);
err = bpf__foreach_event(obj, add_bpf_event, &param);
if (err) {
snprintf(errbuf, sizeof(errbuf),
"Attach events in BPF object failed");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment