perf evlist: Allow reusing the side band thread for more purposes

I.e. so far we had just one event in that side band thread, a dummy one
with attr.bpf_event set, so that 'perf record' can go ahead and ask the
kernel for further information about BPF programs being loaded.

Allow for more than one event to be there, so that we can use it as
well for the upcoming --switch-output-event feature.
Acked-by: default avatarJiri 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-6-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9a399944
...@@ -111,6 +111,7 @@ int perf_evlist__add_sb_event(struct evlist *evlist, ...@@ -111,6 +111,7 @@ int perf_evlist__add_sb_event(struct evlist *evlist,
struct perf_event_attr *attr, struct perf_event_attr *attr,
perf_evsel__sb_cb_t cb, perf_evsel__sb_cb_t cb,
void *data); void *data);
void evlist__set_cb(struct evlist *evlist, perf_evsel__sb_cb_t cb, void *data);
int perf_evlist__start_sb_thread(struct evlist *evlist, int perf_evlist__start_sb_thread(struct evlist *evlist,
struct target *target); struct target *target);
void perf_evlist__stop_sb_thread(struct evlist *evlist); void perf_evlist__stop_sb_thread(struct evlist *evlist);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/mmap.h" #include "util/mmap.h"
#include "util/perf_api_probe.h"
#include <perf/mmap.h> #include <perf/mmap.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <limits.h> #include <limits.h>
...@@ -80,6 +81,19 @@ static void *perf_evlist__poll_thread(void *arg) ...@@ -80,6 +81,19 @@ static void *perf_evlist__poll_thread(void *arg)
return NULL; return NULL;
} }
void evlist__set_cb(struct evlist *evlist, perf_evsel__sb_cb_t cb, void *data)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel) {
evsel->core.attr.sample_id_all = 1;
evsel->core.attr.watermark = 1;
evsel->core.attr.wakeup_watermark = 1;
evsel->side_band.cb = cb;
evsel->side_band.data = data;
}
}
int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target) int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target)
{ {
struct evsel *counter; struct evsel *counter;
...@@ -90,6 +104,15 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target) ...@@ -90,6 +104,15 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, struct target *target)
if (perf_evlist__create_maps(evlist, target)) if (perf_evlist__create_maps(evlist, target))
goto out_delete_evlist; goto out_delete_evlist;
if (evlist->core.nr_entries > 1) {
bool can_sample_identifier = perf_can_sample_identifier();
evlist__for_each_entry(evlist, counter)
perf_evsel__set_sample_id(counter, can_sample_identifier);
perf_evlist__set_id_pos(evlist);
}
evlist__for_each_entry(evlist, counter) { evlist__for_each_entry(evlist, counter) {
if (evsel__open(counter, evlist->core.cpus, evlist->core.threads) < 0) if (evsel__open(counter, evlist->core.cpus, evlist->core.threads) < 0)
goto out_delete_evlist; goto out_delete_evlist;
......
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