perf evlist: Introduce side band thread
This patch introduces side band thread that captures extended information for events like PERF_RECORD_BPF_EVENT. This new thread uses its own evlist that uses ring buffer with very low watermark for lower latency. To use side band thread, we need to: 1. add side band event(s) by calling perf_evlist__add_sb_event(); 2. calls perf_evlist__start_sb_thread(); 3. at the end of perf run, perf_evlist__stop_sb_thread(). In the next patch, we use this thread to handle PERF_RECORD_BPF_EVENT. Committer notes: Add fix by Jiri Olsa for when te sb_tread can't get started and then at the end the stop_sb_thread() segfaults when joining the (non-existing) thread. That can happen when running 'perf top' or 'perf record' as a normal user, for instance. Further checks need to be done on top of this to more graciously handle these possible failure scenarios. Signed-off-by: Song Liu <songliubraving@fb.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stanislav Fomichev <sdf@google.com> Link: http://lkml.kernel.org/r/20190312053051.2690567-15-songliubraving@fb.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
6987561c9e
commit
657ee55319
@@ -54,6 +54,10 @@ struct perf_evlist {
|
||||
struct perf_sample *sample);
|
||||
u64 first_sample_time;
|
||||
u64 last_sample_time;
|
||||
struct {
|
||||
pthread_t th;
|
||||
volatile int done;
|
||||
} thread;
|
||||
};
|
||||
|
||||
struct perf_evsel_str_handler {
|
||||
@@ -87,6 +91,14 @@ int __perf_evlist__add_default_attrs(struct perf_evlist *evlist,
|
||||
|
||||
int perf_evlist__add_dummy(struct perf_evlist *evlist);
|
||||
|
||||
int perf_evlist__add_sb_event(struct perf_evlist **evlist,
|
||||
struct perf_event_attr *attr,
|
||||
perf_evsel__sb_cb_t cb,
|
||||
void *data);
|
||||
int perf_evlist__start_sb_thread(struct perf_evlist *evlist,
|
||||
struct target *target);
|
||||
void perf_evlist__stop_sb_thread(struct perf_evlist *evlist);
|
||||
|
||||
int perf_evlist__add_newtp(struct perf_evlist *evlist,
|
||||
const char *sys, const char *name, void *handler);
|
||||
|
||||
|
Reference in New Issue
Block a user