From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
acme@kernel.org, martin.lau@linux.dev, song@kernel.org,
yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org,
sdf@google.com, haoluo@google.com, jolsa@kernel.org,
quentin@isovalent.com, mykolal@fb.com, bpf@vger.kernel.org
Subject: Re: [RFC bpf-next 7/8] bpftool: add BTF dump "format meta" to dump header/metadata
Date: Fri, 2 Jun 2023 09:57:45 -0700 [thread overview]
Message-ID: <CAEf4BzahDAkuaxOQf10zMv8rKPA0Hno1y6m8R1w=g+X2ryO6Kw@mail.gmail.com> (raw)
In-Reply-To: <20230531201936.1992188-8-alan.maguire@oracle.com>
On Wed, May 31, 2023 at 1:21 PM Alan Maguire <alan.maguire@oracle.com> wrote:
>
> Provide a way to dump BTF header and metadata info via
> bpftool; for example
>
> $ bpftool btf dump file vmliux format meta
> BTF: data size 4963656
> Header: magic 0xeb9f, version 1, flags 0x0, hdr_len 32
> Types: len 2927556, offset 0
> Strings: len 2035881, offset 2927556
> Metadata header found: len 184, offset 4963440, flags 0x1
> Description: 'generated by dwarves v1.25'
> CRC 0x6da2a930 ; base CRC 0x0
> Kind metadata for 20 kinds:
> BTF_KIND_UNKN[ 0] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_INT[ 1] flags 0x0 info_sz 4 elem_sz 0
> BTF_KIND_PTR[ 2] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_ARRAY[ 3] flags 0x0 info_sz 12 elem_sz 0
> BTF_KIND_STRUCT[ 4] flags 0x0 info_sz 0 elem_sz 12
> BTF_KIND_UNION[ 5] flags 0x0 info_sz 0 elem_sz 12
> BTF_KIND_ENUM[ 6] flags 0x0 info_sz 0 elem_sz 8
> BTF_KIND_FWD[ 7] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_TYPEDEF[ 8] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_VOLATILE[ 9] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_CONST[10] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_RESTRICT[11] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_FUNC[12] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_FUNC_PROTO[13] flags 0x0 info_sz 0 elem_sz 8
> BTF_KIND_VAR[14] flags 0x0 info_sz 4 elem_sz 0
> BTF_KIND_DATASEC[15] flags 0x0 info_sz 0 elem_sz 12
> BTF_KIND_FLOAT[16] flags 0x0 info_sz 0 elem_sz 0
> BTF_KIND_DECL_TAG[17] flags 0x1 info_sz 4 elem_sz 0
> BTF_KIND_TYPE_TAG[18] flags 0x1 info_sz 0 elem_sz 0
> BTF_KIND_ENUM64[19] flags 0x0 info_sz 0 elem_sz 12
nit: looks very weird to be right aligned for the "BTF_KIND_xxx"
column, let's align it left here?
Also, btfdump ([0]) emits stats on per-kind basis, and I found it
quite useful on multiple occasions, do you think it would be
worthwhile to add that to bpftool as well. It looks like this in
btfdump's case:
BTF types
=======================================
Total 2293996 bytes (90517 types)
FuncProto: 731420 bytes (21455 types)
Struct: 625944 bytes (7575 types)
Func: 480876 bytes (40073 types)
Enum: 137652 bytes (1721 types)
Ptr: 132180 bytes (11015 types)
Array: 67440 bytes (2810 types)
Union: 57744 bytes (1348 types)
Const: 28140 bytes (2345 types)
Typedef: 20964 bytes (1747 types)
Var: 5024 bytes (314 types)
Datasec: 3780 bytes (1 types)
Enum64: 1500 bytes (7 types)
Fwd: 828 bytes (69 types)
Int: 240 bytes (15 types)
Volatile: 228 bytes (19 types)
Restrict: 24 bytes (2 types)
Float: 12 bytes (1 types)
[0] https://github.com/anakryiko/btfdump
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---
> tools/bpf/bpftool/btf.c | 46 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index 91fcb75babe3..da4257e00ba8 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -504,6 +504,47 @@ static int dump_btf_c(const struct btf *btf,
> return err;
> }
>
[...]
next prev parent reply other threads:[~2023-06-02 16:58 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 20:19 [RFC bpf-next 0/8] bpf: support BTF kind metadata to separate Alan Maguire
2023-05-31 20:19 ` [RFC bpf-next 1/8] btf: add kind metadata encoding to UAPI Alan Maguire
2023-06-01 3:53 ` Alexei Starovoitov
2023-06-01 10:36 ` Alan Maguire
2023-06-01 16:53 ` Alexei Starovoitov
2023-06-02 16:32 ` Andrii Nakryiko
2023-06-02 16:34 ` Andrii Nakryiko
2023-06-02 18:11 ` Alexei Starovoitov
2023-06-02 20:33 ` Andrii Nakryiko
2023-06-05 16:14 ` Alexei Starovoitov
2023-06-05 22:38 ` Andrii Nakryiko
2023-06-06 2:46 ` Alexei Starovoitov
2023-06-06 11:30 ` Toke Høiland-Jørgensen
2023-06-07 11:55 ` Eduard Zingerman
2023-06-07 15:29 ` Yonghong Song
2023-06-07 16:14 ` Eduard Zingerman
2023-06-07 21:47 ` Andrii Nakryiko
2023-06-07 22:05 ` Eduard Zingerman
2023-06-07 22:34 ` Andrii Nakryiko
2023-06-06 16:50 ` Andrii Nakryiko
2023-06-07 1:16 ` Alexei Starovoitov
2023-06-07 21:43 ` Andrii Nakryiko
2023-05-31 20:19 ` [RFC bpf-next 2/8] libbpf: support handling of metadata section in BTF Alan Maguire
2023-06-05 11:01 ` Jiri Olsa
2023-06-05 21:40 ` Andrii Nakryiko
2023-05-31 20:19 ` [RFC bpf-next 3/8] libbpf: use metadata to compute an unknown kind size Alan Maguire
2023-05-31 20:19 ` [RFC bpf-next 4/8] btf: support kernel parsing of BTF with metadata, use it to parse BTF with unknown kinds Alan Maguire
2023-06-07 19:51 ` Eduard Zingerman
2023-05-31 20:19 ` [RFC bpf-next 5/8] libbpf: add metadata encoding support Alan Maguire
2023-05-31 20:19 ` [RFC bpf-next 6/8] btf: generate metadata for vmlinux/module BTF Alan Maguire
2023-05-31 20:19 ` [RFC bpf-next 7/8] bpftool: add BTF dump "format meta" to dump header/metadata Alan Maguire
2023-06-01 16:33 ` Quentin Monnet
2023-06-02 16:57 ` Andrii Nakryiko [this message]
2023-05-31 20:19 ` [RFC bpf-next 8/8] selftests/bpf: test kind encoding/decoding Alan Maguire
2023-05-31 20:19 ` [RFC dwarves] dwarves: encode BTF metadata if --btf_gen_meta is set Alan Maguire
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='CAEf4BzahDAkuaxOQf10zMv8rKPA0Hno1y6m8R1w=g+X2ryO6Kw@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/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).