]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
perf symbols: Introduce DSO_BINARY_TYPE__BPF_PROG_INFO
authorSong Liu <songliubraving@fb.com>
Tue, 12 Mar 2019 05:30:48 +0000 (22:30 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 19 Mar 2019 19:52:07 +0000 (16:52 -0300)
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>
tools/perf/util/dso.c
tools/perf/util/dso.h
tools/perf/util/symbol.c

index ab8a455d2283fa153caee80b5f35e19c9b0cb5dd..e059976d9d9365abeb943647b456fbfa560e7775 100644 (file)
@@ -184,6 +184,7 @@ int dso__read_binary_type_filename(const struct dso *dso,
        case DSO_BINARY_TYPE__KALLSYMS:
        case DSO_BINARY_TYPE__GUEST_KALLSYMS:
        case DSO_BINARY_TYPE__JAVA_JIT:
+       case DSO_BINARY_TYPE__BPF_PROG_INFO:
        case DSO_BINARY_TYPE__NOT_FOUND:
                ret = -1;
                break;
index bb417c54c25a3abfe26ac2f35fddd70405ed907d..6e3f63781e51ad2f8294dbbe8645c9ddf39a62cd 100644 (file)
@@ -14,6 +14,7 @@
 
 struct machine;
 struct map;
+struct perf_env;
 
 enum dso_binary_type {
        DSO_BINARY_TYPE__KALLSYMS = 0,
@@ -35,6 +36,7 @@ enum dso_binary_type {
        DSO_BINARY_TYPE__KCORE,
        DSO_BINARY_TYPE__GUEST_KCORE,
        DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
+       DSO_BINARY_TYPE__BPF_PROG_INFO,
        DSO_BINARY_TYPE__NOT_FOUND,
 };
 
@@ -189,6 +191,12 @@ struct dso {
                u64              debug_frame_offset;
                u64              eh_frame_hdr_offset;
        } data;
+       /* bpf prog information */
+       struct {
+               u32             id;
+               u32             sub_id;
+               struct perf_env *env;
+       } bpf_prog;
 
        union { /* Tool specific area */
                void     *priv;
index 58442ca5e3c4bac153d130b915e76f82695abb7c..5cbad55cd99dfbee9729b64331ea384da46cb2a8 100644 (file)
@@ -1455,6 +1455,7 @@ static bool dso__is_compatible_symtab_type(struct dso *dso, bool kmod,
        case DSO_BINARY_TYPE__BUILD_ID_CACHE_DEBUGINFO:
                return true;
 
+       case DSO_BINARY_TYPE__BPF_PROG_INFO:
        case DSO_BINARY_TYPE__NOT_FOUND:
        default:
                return false;