On Wed, Feb 27, 2019 at 09:06:37PM -0800, Song Liu wrote:

SNIP

>  
> +static int process_bpf_btf(struct feat_fd *ff, void *data __maybe_unused)
> +{
> +     struct perf_env *env = &ff->ph->env;
> +     u32 count, i;
> +
> +     if (do_read_u32(ff, &count))
> +             return -1;
> +
> +     down_write(&env->bpf_progs.lock);
> +
> +     for (i = 0; i < count; ++i) {
> +             struct btf_node *node;
> +             u32 id, data_size;
> +
> +             if (do_read_u32(ff, &id))
> +                     return -1;
> +             if (do_read_u32(ff, &data_size))
> +                     return -1;
> +
> +             node = malloc(sizeof(struct btf_node) + data_size);
> +             if (!node)
> +                     return -1;
> +
> +             node->id = id;
> +             node->data_size = data_size;
> +
> +             if (__do_read(ff, node->data, data_size)) {
> +                     free(node);
> +                     return -1;
> +             }
> +
> +             /* endian mismatch, drop the btf, continue */
> +             if (ff->ph->needs_swap) {
> +                     free(node);
> +                     continue;
> +             }

again, we can check for needs_swap in the begining,
display warning and skip the loop in here

perhaps we should warn just once for all the bpf data
missed when needs_swap is set

jirka

Reply via email to