[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <55885497-4542-4FED-97E0-64664059FFC3@fb.com>
Date: Tue, 19 Feb 2019 14:21:03 +0000
From: Song Liu <songliubraving@...com>
To: Jiri Olsa <jolsa@...hat.com>
CC: Netdev <netdev@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
"ast@...nel.org" <ast@...nel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>,
Kernel Team <Kernel-team@...com>,
"peterz@...radead.org" <peterz@...radead.org>,
"acme@...hat.com" <acme@...hat.com>,
"jolsa@...nel.org" <jolsa@...nel.org>,
"namhyung@...nel.org" <namhyung@...nel.org>
Subject: Re: [PATCH v3 perf,bpf 05/11] perf, bpf: save bpf_prog_info in a
rbtree in perf_env
> On Feb 19, 2019, at 12:51 AM, Jiri Olsa <jolsa@...hat.com> wrote:
>
> On Tue, Feb 19, 2019 at 05:52:20AM +0000, Song Liu wrote:
>>
>>
>>> On Feb 17, 2019, at 3:05 PM, Jiri Olsa <jolsa@...hat.com> wrote:
>>>
>>> On Fri, Feb 15, 2019 at 01:53:48PM -0800, Song Liu wrote:
>>>
>>> SNIP
>>>
>>>> info_linear = bpf_program__get_prog_info_linear(fd, arrays);
>>>> if (IS_ERR_OR_NULL(info_linear)) {
>>>> @@ -151,8 +165,8 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
>>>> machine, process);
>>>> }
>>>>
>>>> - /* Synthesize PERF_RECORD_BPF_EVENT */
>>>> if (opts->bpf_event) {
>>>> + /* Synthesize PERF_RECORD_BPF_EVENT */
>>>> *bpf_event = (struct bpf_event){
>>>> .header = {
>>>> .type = PERF_RECORD_BPF_EVENT,
>>>> @@ -165,6 +179,19 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_tool *tool,
>>>> memcpy(bpf_event->tag, info->tag, BPF_TAG_SIZE);
>>>> memset((void *)event + event->header.size, 0, machine->id_hdr_size);
>>>> event->header.size += machine->id_hdr_size;
>>>> +
>>>> + /* save bpf_prog_info to env */
>>>> + info_node = malloc(sizeof(struct bpf_prog_info_node));
>>>> + if (info_node) {
>>>> + info_node->info_linear = info_linear;
>>>> + perf_env__insert_bpf_prog_info(env, info_node);
>>>> + info_linear = NULL;
>>>> + }
>>>
>>> what if the allocation fails? we don't care?
>>>
>>> jirka
>>
>> My original plan is to just ignore it and accept that this program
>> doesn't have annotation. Any suggestion on what would be a better
>> approach?
>
> there's an error path in the function, I'd bail out if the malloc fails
>
> jirka
If we go to bail out here, we will skip processing PERF_RECORD_BPF_EVENT.
When malloc fails, this is still valuable information that we should try
to save. So I think we don't have to bail out here. I will add a comment
to explain this.
Thanks,
Song
Powered by blists - more mailing lists