perf evsel: Store backpointer to attached bpf_object

We may want to get to this bpf_object, to search for other BPF programs,
etc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-3y8hrb6lszjfi23vjlic3cib@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2620b7e3
...@@ -763,7 +763,7 @@ int bpf__foreach_event(struct bpf_object *obj, ...@@ -763,7 +763,7 @@ int bpf__foreach_event(struct bpf_object *obj,
if (priv->is_tp) { if (priv->is_tp) {
fd = bpf_program__fd(prog); fd = bpf_program__fd(prog);
err = (*func)(priv->sys_name, priv->evt_name, fd, arg); err = (*func)(priv->sys_name, priv->evt_name, fd, obj, arg);
if (err) { if (err) {
pr_debug("bpf: tracepoint call back failed, stop iterate\n"); pr_debug("bpf: tracepoint call back failed, stop iterate\n");
return err; return err;
...@@ -788,7 +788,7 @@ int bpf__foreach_event(struct bpf_object *obj, ...@@ -788,7 +788,7 @@ int bpf__foreach_event(struct bpf_object *obj,
return fd; return fd;
} }
err = (*func)(tev->group, tev->event, fd, arg); err = (*func)(tev->group, tev->event, fd, obj, arg);
if (err) { if (err) {
pr_debug("bpf: call back failed, stop iterate\n"); pr_debug("bpf: call back failed, stop iterate\n");
return err; return err;
......
...@@ -46,7 +46,7 @@ struct parse_events_term; ...@@ -46,7 +46,7 @@ struct parse_events_term;
#define PERF_BPF_PROBE_GROUP "perf_bpf_probe" #define PERF_BPF_PROBE_GROUP "perf_bpf_probe"
typedef int (*bpf_prog_iter_callback_t)(const char *group, const char *event, typedef int (*bpf_prog_iter_callback_t)(const char *group, const char *event,
int fd, void *arg); int fd, struct bpf_object *obj, void *arg);
#ifdef HAVE_LIBBPF_SUPPORT #ifdef HAVE_LIBBPF_SUPPORT
struct bpf_object *bpf__prepare_load(const char *filename, bool source); struct bpf_object *bpf__prepare_load(const char *filename, bool source);
......
...@@ -234,6 +234,7 @@ void perf_evsel__init(struct perf_evsel *evsel, ...@@ -234,6 +234,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
evsel->scale = 1.0; evsel->scale = 1.0;
evsel->max_events = ULONG_MAX; evsel->max_events = ULONG_MAX;
evsel->evlist = NULL; evsel->evlist = NULL;
evsel->bpf_obj = NULL;
evsel->bpf_fd = -1; evsel->bpf_fd = -1;
INIT_LIST_HEAD(&evsel->node); INIT_LIST_HEAD(&evsel->node);
INIT_LIST_HEAD(&evsel->config_terms); INIT_LIST_HEAD(&evsel->config_terms);
......
...@@ -82,6 +82,8 @@ enum perf_tool_event { ...@@ -82,6 +82,8 @@ enum perf_tool_event {
PERF_TOOL_DURATION_TIME = 1, PERF_TOOL_DURATION_TIME = 1,
}; };
struct bpf_object;
/** struct perf_evsel - event selector /** struct perf_evsel - event selector
* *
* @evlist - evlist this evsel is in, if it is in one. * @evlist - evlist this evsel is in, if it is in one.
...@@ -152,6 +154,7 @@ struct perf_evsel { ...@@ -152,6 +154,7 @@ struct perf_evsel {
char *group_name; char *group_name;
bool cmdline_group_boundary; bool cmdline_group_boundary;
struct list_head config_terms; struct list_head config_terms;
struct bpf_object *bpf_obj;
int bpf_fd; int bpf_fd;
bool auto_merge_stats; bool auto_merge_stats;
bool merged_stat; bool merged_stat;
......
...@@ -630,7 +630,7 @@ struct __add_bpf_event_param { ...@@ -630,7 +630,7 @@ struct __add_bpf_event_param {
struct list_head *head_config; struct list_head *head_config;
}; };
static int add_bpf_event(const char *group, const char *event, int fd, static int add_bpf_event(const char *group, const char *event, int fd, struct bpf_object *obj,
void *_param) void *_param)
{ {
LIST_HEAD(new_evsels); LIST_HEAD(new_evsels);
...@@ -672,6 +672,7 @@ static int add_bpf_event(const char *group, const char *event, int fd, ...@@ -672,6 +672,7 @@ static int add_bpf_event(const char *group, const char *event, int fd,
pr_debug("adding %s:%s to %p\n", pr_debug("adding %s:%s to %p\n",
group, event, pos); group, event, pos);
pos->bpf_fd = fd; pos->bpf_fd = fd;
pos->bpf_obj = obj;
} }
list_splice(&new_evsels, list); list_splice(&new_evsels, list);
return 0; return 0;
......
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