Re: [PATCH v6 perf,bpf 06/15] perf, bpf: save bpf_prog_info in a rbtree in perf_env

From: Song Liu
Date: Thu Mar 07 2019 - 12:22:27 EST




> On Mar 7, 2019, at 6:05 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Tue, Mar 05, 2019 at 11:13:50PM -0800, Song Liu wrote:
>> bpf_prog_info contains information necessary to annotate bpf programs.
>> This patch saves bpf_prog_info for bpf programs loaded in the system.
>>
>> Some big picture of the next few patches:
>>
>> To fully annotate BPF programs with source code mapping, 4 different
>> information are needed:
>> 1) PERF_RECORD_KSYMBOL
>> 2) PERF_RECORD_BPF_EVENT
>> 3) bpf_prog_info
>> 4) btf
>>
>> Before this set, 1) and 2) in the list are already saved to perf.data
>> file. For BPF programs that are already loaded before perf run, 1) and 2)
>> are synthesized by perf_event__synthesize_bpf_events(). For short living
>> BPF programs, 1) and 2) are generated by kernel.
>>
>> This set handles 3) and 4) from the list. Again, it is necessary to handle
>> existing BPF program and short living program separately.
>>
>> This patch handles 3) for exising BPF programs while synthesizing 1) and
>> 2) in perf_event__synthesize_bpf_events(). These data are stored in
>> perf_env. The next patch saves these data from perf_env to perf.data as
>> headers.
>>
>> Similarly, the two patches after the next saves 4) of existing BPF
>> programs to perf_env and perf.data.
>>
>> Another patch later will handle 3) and 4) for short living BPF programs
>> by monitoring 1) and 2) in a dedicate thread.
>>
>
> thanks for the changelog
>
> SNIP
>
>> +
>> + /* save bpf_prog_info to env */
>> + info_node = malloc(sizeof(struct bpf_prog_info_node));
>> +
>> + /*
>> + * Do not bail out for !info_node, as we still want to
>> + * call perf_tool__process_synth_event()
>> + */
>
> well, we are out of memory, so I dont think perf_tool__process_synth_event
> will get too far.. also the perf_env data would be inconsistent with what
> you store as event.. how can that work?
>
> jirka

Yeah, that makes sense. Let's bail out then.

Thanks,
Song

>> + if (info_node) {
>> + info_node->info_linear = info_linear;
>> + perf_env__insert_bpf_prog_info(env, info_node);
>> + info_linear = NULL;
>> + }
>
> SNIP