Re: [PATCH v4 perf,bpf 07/15] perf, bpf: save bpf_prog_info information as headers to perf.data

From: Song Liu
Date: Wed Feb 27 2019 - 12:29:13 EST




> On Feb 27, 2019, at 5:21 AM, Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> On Mon, Feb 25, 2019 at 04:20:11PM -0800, Song Liu wrote:
>
> SNIP
>
>> + if (info_len > sizeof(struct bpf_prog_info)) {
>> + pr_warning("detected invalid bpf_prog_info\n");
>> + goto out;
>> + }
>> +
>> + info_linear = malloc(sizeof(struct bpf_prog_info_linear) +
>> + data_len);
>> + if (!info_linear)
>> + goto out;
>> + info_linear->info_len = sizeof(struct bpf_prog_info);
>> + info_linear->data_len = data_len;
>> + if (do_read_u64(ff, (u64 *)(&info_linear->arrays)))
>> + goto out;
>> + if (__do_read(ff, &info_linear->info, info_len))
>> + goto out;
>> + if (info_len < sizeof(struct bpf_prog_info))
>> + memset(((void *)(&info_linear->info)) + info_len, 0,
>> + sizeof(struct bpf_prog_info) - info_len);
>> +
>> + if (__do_read(ff, info_linear->data, data_len))
>> + goto out;
>> +
>> + /* endian mismatch, drop the info, continue */
>
> so there's no way we can swap the data? why?
>
> jirka

Yes, we can swap the data. OTOH, the set is big enough. How about we
implement the swap later? Running perf-report on a system of with
different endianness is a relatively rare case.

Thanks,
Song



>> + if (ff->ph->needs_swap) {
>> + free(info_linear);
>> + continue;
>> + }
>
> SNIP