Re: [PATCH v10 bpf-next 09/10] bpftool: Update doc to describe bpftool btf dump .. format metadata
| Newsgroups | org.kernel.vger.dwarves,org.kernel.vger.bpf |
|---|---|
| Message-ID | <ee7305416a59102140d18d5d7f544061d8d82658dda98768c209905d5db222e6@mail.kernel.org> |
> diff --git a/tools/bpf/bpftool/Documentation/bpftool-btf.rst b/tools/bpf/bpftool/Documentation/bpftool-btf.rst
> --- a/tools/bpf/bpftool/Documentation/bpftool-btf.rst
> +++ b/tools/bpf/bpftool/Documentation/bpftool-btf.rst
[ ... ]
> @@ -267,3 +268,26 @@
> [104861] FUNC 'smbus_do_alert' type_id=84827 linkage=static
> +
> +Display BTF metadata from file vmlinux
> +
> +**# bpftool btf dump file vmlinux format meta**
> +
> +::
> +
> + size 5161076
> + magic 0xeb9f
> + version 1
> + flags 0x1
> + hdr_len 40
> + type_len 3036368
> + type_off 0
> + str_len 2124588
> + str_off 3036368
> + layout_len 80
> + layout_off 5160956
> + kind 0 UNKNOWN info_sz 0 elem_sz 0 flags 0
> + kind 1 INT info_sz 0 elem_sz 0 flags 0
> + kind 2 PTR info_sz 0 elem_sz 0 flags 0
> + kind 3 ARRAY info_sz 0 elem_sz 0 flags 0
> + kind 4 STRUCT info_sz 0 elem_sz 0 flags 0
Does this example reflect actual tool output? A few values appear
inconsistent with the implementation in dump_btf_meta() and the
layout encoding in libbpf:
The kind layout values are all zeros, but the layouts[] array in
tools/lib/bpf/btf.c populates non-zero values for known kinds:
[BTF_KIND_INT] = { sizeof(__u32), 0, 0 }, /* info_sz=4 */
[BTF_KIND_ARRAY] = { sizeof(struct btf_array), 0, 0 }, /* info_sz=12 */
[BTF_KIND_STRUCT] = { 0, sizeof(struct btf_member), 0 }, /* elem_sz=12 */
The implementation commit (62f2c6445a46) also shows the correct
non-zero values in its own example:
kind 1 INT info_sz 4 elem_sz 0 flags 0
kind 3 ARRAY info_sz 12 elem_sz 0 flags 0
kind 4 STRUCT info_sz 0 elem_sz 12 flags 0
Would it be worth regenerating this example from an actual
bpftool run to make sure the values match?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/22482435858
AI-authorship-score: low
AI-authorship-explanation: Straightforward RST documentation update with iterative human review history spanning 2023-2026, typical of a developer documenting their own feature.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: Documentation example output does not match actual tool behavior; kind layout values are all zeros when the implementation produces non-zero values for known kinds.