Re: [PATCH v10 bpf-next 04/10] libbpf: Add layout encoding support

Alexei Starovoitov <[email protected]>
Newsgroups org.kernel.vger.dwarves,org.kernel.vger.bpf
Message-ID <CAADnVQ+xtkQ1hDpwg+RiUaxdwQHZbtW-PjuqTrob3xEVNEY1vQ@mail.gmail.com>
On Fri, Feb 27, 2026 at 2:05 AM Alan Maguire <[email protected]> wrote:
>
> Support encoding of BTF layout data via btf__new_empty_opts().
>
> Current supported opts are base_btf and add_layout.
>
> Layout information is maintained in btf.c in the layouts[] array;
> when BTF is created with the add_layout option it represents the
> current view of supported BTF kinds.
>
> Signed-off-by: Alan Maguire <[email protected]>
> ---
>  tools/lib/bpf/btf.c      | 62 ++++++++++++++++++++++++++++++++++++++--
>  tools/lib/bpf/btf.h      | 20 +++++++++++++
>  tools/lib/bpf/libbpf.map |  1 +
>  3 files changed, 80 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
> index db13c15a0049..0c7fc0b49f20 100644
> --- a/tools/lib/bpf/btf.c
> +++ b/tools/lib/bpf/btf.c
> @@ -29,6 +29,35 @@
>
>  static struct btf_type btf_void;
>
> +/* Describe how kinds are laid out; some have a singular element following the "struct btf_type",
> + * some have BTF_INFO_VLEN(t->info) elements.  Specify sizes for both.  Flags are currently unused.
> + * Kind layout can be optionally added to the BTF representation in a dedicated section to
> + * facilitate parsing.  New kinds must be added here.
> + */

Pls use proper kernel comment style in any new code.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.