From: John Fastabend <john.fastabend@gmail.com>
To: Andrii Nakryiko <andriin@fb.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org, ast@fb.com,
daniel@iogearbox.net
Cc: andrii.nakryiko@gmail.com, kernel-team@fb.com,
Andrii Nakryiko <andriin@fb.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: RE: [PATCH bpf-next 2/9] libbpf: remove assumption of single contiguous memory for BTF data
Date: Thu, 24 Sep 2020 08:21:27 -0700 [thread overview]
Message-ID: <5f6cb9778cbd7_4939c208b8@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <20200923155436.2117661-3-andriin@fb.com>
Andrii Nakryiko wrote:
> Refactor internals of struct btf to remove assumptions that BTF header, type
> data, and string data are layed out contiguously in a memory in a single
> memory allocation. Now we have three separate pointers pointing to the start
> of each respective are: header, types, strings. In the next patches, these
> pointers will be re-assigned to point to independently allocated memory areas,
> if BTF needs to be modified.
>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
[...]
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -27,18 +27,37 @@
> static struct btf_type btf_void;
>
> struct btf {
> - union {
> - struct btf_header *hdr;
> - void *data;
> - };
> + void *raw_data;
> + __u32 raw_size;
> +
> + /*
> + * When BTF is loaded from ELF or raw memory it is stored
> + * in contiguous memory block, pointed to by raw_data pointer, and
> + * hdr, types_data, and strs_data point inside that memory region to
> + * respective parts of BTF representation:
I find the above comment a bit confusing. The picture though is great. How
about something like,
When BTF is loaded from an ELF or raw memory it is stored
in a continguous memory block. The hdr, type_data, and strs_data
point inside that memory region to their respective parts of BTF
representation
> + *
> + * +--------------------------------+
> + * | Header | Types | Strings |
> + * +--------------------------------+
> + * ^ ^ ^
> + * | | |
> + * hdr | |
> + * types_data-+ |
> + * strs_data------------+
> + */
> + struct btf_header *hdr;
> + void *types_data;
> + void *strs_data;
> +
> + /* type ID to `struct btf_type *` lookup index */
> __u32 *type_offs;
> __u32 type_offs_cap;
> - const char *strings;
> - void *nohdr_data;
> - void *types_data;
> __u32 nr_types;
> - __u32 data_size;
> +
> + /* BTF object FD, if loaded into kernel */
> int fd;
> +
> + /* Pointer size (in bytes) for a target architecture of this BTF */
> int ptr_sz;
> };
>
Thanks,
John
next prev parent reply other threads:[~2020-09-24 15:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 15:54 [PATCH bpf-next 0/9] libbpf: BTF writer APIs Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 1/9] libbpf: refactor internals of BTF type index Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 2/9] libbpf: remove assumption of single contiguous memory for BTF data Andrii Nakryiko
2020-09-24 15:21 ` John Fastabend [this message]
2020-09-24 20:25 ` Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 3/9] libbpf: generalize common logic for managing dynamically-sized arrays Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 4/9] libbpf: extract generic string hashing function for reuse Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 5/9] libbpf: allow modification of BTF and add btf__add_str API Andrii Nakryiko
2020-09-24 15:56 ` John Fastabend
2020-09-24 20:27 ` Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 6/9] libbpf: add btf__new_empty() to create an empty BTF object Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 7/9] libbpf: add BTF writing APIs Andrii Nakryiko
2020-09-24 15:59 ` John Fastabend
2020-09-25 3:55 ` Alexei Starovoitov
2020-09-25 6:21 ` Andrii Nakryiko
2020-09-25 15:37 ` Alexei Starovoitov
2020-09-25 16:53 ` Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 8/9] libbpf: add btf__str_by_offset() as a more generic variant of name_by_offset Andrii Nakryiko
2020-09-23 15:54 ` [PATCH bpf-next 9/9] selftests/bpf: test BTF writing APIs Andrii Nakryiko
2020-09-24 15:16 ` [PATCH bpf-next 0/9] libbpf: BTF writer APIs John Fastabend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f6cb9778cbd7_4939c208b8@john-XPS-13-9370.notmuch \
--to=john.fastabend@gmail.com \
--cc=acme@redhat.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).