perf bpf: Decouple creating the evlist from adding the SB event
Renaming bpf_event__add_sb_event() to evlist__add_sb_event() and requiring that the evlist be allocated beforehand. This will allow using the same side band thread and evlist to be used for multiple purposes in addition to react to PERF_RECORD_BPF_EVENT soon after they are generated. Acked-by: Jiri Olsa <jolsa@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Song Liu <songliubraving@fb.com> Link: http://lore.kernel.org/lkml/20200429131106.27974-4-acme@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -1705,39 +1705,26 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list,
|
||||
return leader;
|
||||
}
|
||||
|
||||
int perf_evlist__add_sb_event(struct evlist **evlist,
|
||||
int perf_evlist__add_sb_event(struct evlist *evlist,
|
||||
struct perf_event_attr *attr,
|
||||
perf_evsel__sb_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct evsel *evsel;
|
||||
bool new_evlist = (*evlist) == NULL;
|
||||
|
||||
if (*evlist == NULL)
|
||||
*evlist = evlist__new();
|
||||
if (*evlist == NULL)
|
||||
return -1;
|
||||
|
||||
if (!attr->sample_id_all) {
|
||||
pr_warning("enabling sample_id_all for all side band events\n");
|
||||
attr->sample_id_all = 1;
|
||||
}
|
||||
|
||||
evsel = perf_evsel__new_idx(attr, (*evlist)->core.nr_entries);
|
||||
evsel = perf_evsel__new_idx(attr, evlist->core.nr_entries);
|
||||
if (!evsel)
|
||||
goto out_err;
|
||||
return -1;
|
||||
|
||||
evsel->side_band.cb = cb;
|
||||
evsel->side_band.data = data;
|
||||
evlist__add(*evlist, evsel);
|
||||
evlist__add(evlist, evsel);
|
||||
return 0;
|
||||
|
||||
out_err:
|
||||
if (new_evlist) {
|
||||
evlist__delete(*evlist);
|
||||
*evlist = NULL;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void *perf_evlist__poll_thread(void *arg)
|
||||
|
Reference in New Issue
Block a user