Subject: Re: [WORKS!] Re: [PATCH v9 perf,bpf 12/15] perf, bpf: enable annotation of bpf program

From: Arnaldo Carvalho de Melo <[email-masked]>
Date: Tue, 19 Mar 2019 13:55:31 -0300

Em Tue, Mar 19, 2019 at 04:51:44PM +0000, Song Liu escreveu:
> 
> 
> > On Mar 19, 2019, at 7:52 AM, Arnaldo Carvalho de Melo <[email-masked]> wrote:
> > 
> > Em Tue, Mar 19, 2019 at 11:14:35AM -0300, Arnaldo Carvalho de Melo escreveu:
> >> 
> >> Now the test is really being performed, the test-all.bin feature
> >> detection fast path is working, proceeding.
> > 
> > Now it all works, really nice!
> > 
> > I added a 'Committer testing' section with all the steps to test this
> > and pushed to:
> > 
> > https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=6530d44e7dc1d41c73fe70b9e6ea1b9cabebb57f
> 
> Thanks Arnaldo! This looks great!
> 
> I will rebase https://lkml.org/lkml/2019/3/14/681 on top of this branch
> and resend. 

I just found one new bug, that may appear now since I took a series of
fixes found by gcc's ASan feature, i.e. on the exit path we're crashing
on:

[root@quaco ~]# 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]
[root@quaco ~]#
[root@quaco ~]# addr2line -fe ~/bin/perf 0x4dffb7
dso_cache__free
/home/acme/git/perf/tools/perf/util/dso.c:713

And that is because of that union:

+       union {
+               /* dso data file */
+               struct {
+                       struct rb_root   cache;
+                       int              fd;
+                       int              status;
+                       u32              status_seen;
+                       size_t           file_size;
+                       struct list_head open_entry;
+                       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;
+       };

On the dso exit path, it is trying to traverse the data.cache rbtree,
when what is that is that bpf_prog.id, etc, I'll just remove the union
for now, later we can do the data.cache access or bpf_prog based on some
other test.