[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e4c11465-31a9-5dd3-7408-b0d5665bc391@fb.com>
Date: Fri, 8 Feb 2019 17:12:53 +0000
From: Yonghong Song <yhs@...com>
To: Andrii Nakryiko <andriin@...com>,
"alexei.starovoitov@...il.com" <alexei.starovoitov@...il.com>,
"andrii.nakryiko@...il.com" <andrii.nakryiko@...il.com>,
Song Liu <songliubraving@...com>,
"Alexei Starovoitov" <ast@...com>, Martin Lau <kafai@...com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Kernel Team <Kernel-team@...com>,
"daniel@...earbox.net" <daniel@...earbox.net>
Subject: Re: [PATCH v3 bpf-next 3/4] btf: expose API to work with raw btf_ext
data
On 2/7/19 6:55 PM, Andrii Nakryiko wrote:
> This patch changes struct btf_ext to retain original data in sequential
> block of memory, which makes it possible to expose
> btf_ext__get_raw_data() interface, that's similar to
> btf__get_raw_data(), allowing users of libbpf to get access to raw
> representation of .BTF.ext section.
>
> Signed-off-by: Andrii Nakryiko <andriin@...com>
> ---
> tools/lib/bpf/btf.c | 85 +++++++++++++++++++++-------------------
> tools/lib/bpf/btf.h | 2 +
> tools/lib/bpf/libbpf.map | 1 +
> 3 files changed, 47 insertions(+), 41 deletions(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index 8730f6c3be9e..c87cc3d71b9f 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -41,9 +41,8 @@ struct btf {
>
> struct btf_ext_info {
> /*
> - * info points to a deep copy of the individual info section
> - * (e.g. func_info and line_info) from the .BTF.ext.
> - * It does not include the __u32 rec_size.
> + * info points to the individual info section (e.g. func_info and
> + * line_info) from the .BTF.ext. It does not include the __u32 rec_size.
> */
> void *info;
> __u32 rec_size;
> @@ -51,8 +50,13 @@ struct btf_ext_info {
> };
>
> struct btf_ext {
> + union {
> + struct btf_ext_header *hdr;
> + void *data;
> + };
> struct btf_ext_info func_info;
> struct btf_ext_info line_info;
> + __u32 data_size;
> };
>
> struct btf_ext_info_sec {
> @@ -603,19 +607,13 @@ struct btf_ext_sec_copy_param {
> };
>
> static int btf_ext_copy_info(struct btf_ext *btf_ext,
> - __u8 *data, __u32 data_size,
> struct btf_ext_sec_copy_param *ext_sec)
Overall looks good. Since we do not really "copy" info any more,
rather we try to "setup" info based on btf_ext. Maybe changing
all function and structure names with "_copy_" to "_setup_"?
> {
> - const struct btf_ext_header *hdr = (struct btf_ext_header *)data;
> const struct btf_ext_info_sec *sinfo;
> struct btf_ext_info *ext_info;
> __u32 info_left, record_size;
> /* The start of the info sec (including the __u32 record_size). */
> - const void *info;
> -
> - /* data and data_size do not include btf_ext_header from now on */
> - data = data + hdr->hdr_len;
> - data_size -= hdr->hdr_len;
> + void *info;
[...]
Powered by blists - more mailing lists