[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190217230532.GC7443@krava>
Date: Mon, 18 Feb 2019 00:05:32 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: Song Liu <songliubraving@...com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
ast@...nel.org, daniel@...earbox.net, kernel-team@...com,
peterz@...radead.org, acme@...hat.com, jolsa@...nel.org,
namhyung@...nel.org
Subject: Re: [PATCH v3 perf,bpf 06/11] perf, bpf: save bpf_prog_info
information as headers to perf.data
On Fri, Feb 15, 2019 at 01:53:49PM -0800, Song Liu wrote:
SNIP
> +static int process_bpf_prog_info(struct feat_fd *ff,
> + void *data __maybe_unused)
> +{
> + struct bpf_prog_info_linear *info_linear;
> + struct bpf_prog_info_node *info_node;
> + struct perf_env *env = &ff->ph->env;
> + u32 count, i;
> + int err = -1;
> +
> + if (do_read_u32(ff, &count))
> + return -1;
> +
> + down_write(&env->bpf_progs.bpf_info_lock);
> +
> + for (i = 0; i < count; ++i) {
> + u32 info_len, data_len;
> +
> + info_linear = NULL;
> + info_node = NULL;
> + if (do_read_u32(ff, &info_len))
> + goto out;
> + if (do_read_u32(ff, &data_len))
> + goto out;
> +
> + 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;
hum, hows the endianity swap handled for struct bpf_prog_info?
> + 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;
and the data?
thanks,
jirka
Powered by blists - more mailing lists