Skip to content

Commit 9b86d04

Browse files
liu-song-6acmel
authored andcommitted
perf symbols: Introduce DSO_BINARY_TYPE__BPF_PROG_INFO
Introduce a new dso type DSO_BINARY_TYPE__BPF_PROG_INFO for BPF programs. In symbol__disassemble(), DSO_BINARY_TYPE__BPF_PROG_INFO dso will call into a new function symbol__disassemble_bpf() in an upcoming patch, where annotation line information is filled based bpf_prog_info and btf saved in given perf_env. Committer notes: Removed the unnamed union with 'bpf_prog' and 'cache' in 'struct dso', to fix this bug when exiting 'perf top': # perf top perf: Segmentation fault -------- backtrace -------- perf[0x5a785a] /lib64/libc.so.6(+0x385bf)[0x7fd68443c5bf] perf(rb_first+0x2b)[0x4d6eeb] perf(dso__delete+0xb7)[0x4dffb7] perf[0x4f9e37] perf(perf_session__delete+0x64)[0x504df4] perf(cmd_top+0x1957)[0x454467] perf[0x4aad18] perf(main+0x61c)[0x42ec7c] /lib64/libc.so.6(__libc_start_main+0xf2)[0x7fd684428412] perf(_start+0x2d)[0x42eead] # # addr2line -fe ~/bin/perf 0x4dffb7 dso_cache__free /home/acme/git/perf/tools/perf/util/dso.c:713 That is trying to access the dso->data.cache, and that is not used with BPF programs, so we end up accessing what is in bpf_prog.first_member, b00m. Signed-off-by: Song Liu <songliubraving@fb.com> Reviewed-by: Jiri Olsa <jolsa@kernel.org> 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> Cc: kernel-team@fb.com Link: http://lkml.kernel.org/r/20190312053051.2690567-13-songliubraving@fb.com [ split from a larger patch ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 31be947 commit 9b86d04

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

tools/perf/util/dso.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
184184
case DSO_BINARY_TYPE__KALLSYMS:
185185
case DSO_BINARY_TYPE__GUEST_KALLSYMS:
186186
case DSO_BINARY_TYPE__JAVA_JIT:
187+
case DSO_BINARY_TYPE__BPF_PROG_INFO:
187188
case DSO_BINARY_TYPE__NOT_FOUND:
188189
ret = -1;
189190
break;

tools/perf/util/dso.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
struct machine;
1616
struct map;
17+
struct perf_env;
1718

1819
enum dso_binary_type {
1920
DSO_BINARY_TYPE__KALLSYMS = 0,
@@ -35,6 +36,7 @@ enum dso_binary_type {
3536
DSO_BINARY_TYPE__KCORE,
3637
DSO_BINARY_TYPE__GUEST_KCORE,
3738
DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
39+
DSO_BINARY_TYPE__BPF_PROG_INFO,
3840
DSO_BINARY_TYPE__NOT_FOUND,
3941
};
4042

@@ -189,6 +191,12 @@ struct dso {
189191
u64 debug_frame_offset;
190192
u64 eh_frame_hdr_offset;
191193
} data;
194+
/* bpf prog information */
195+
struct {
196+
u32 id;
197+
u32 sub_id;
198+
struct perf_env *env;
199+
} bpf_prog;
192200

193201
union { /* Tool specific area */
194202
void *priv;

tools/perf/util/symbol.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
14551455
case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
14561456
return true;
14571457

1458+
case DSO_BINARY_TYPE__BPF_PROG_INFO:
14581459
case DSO_BINARY_TYPE__NOT_FOUND:
14591460
default:
14601461
return false;

0 commit comments

Comments
 (0)