All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Quentin Monnet <qmo@kernel.org>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	dwarves@vger.kernel.org, bpf <bpf@vger.kernel.org>,
	Thierry Treyer <ttreyer@meta.com>
Subject: Re: [PATCH v5 bpf-next 3/9] libbpf: use kind layout to compute an unknown kind size
Date: Thu, 29 May 2025 13:53:08 +0100	[thread overview]
Message-ID: <4cc43d09-50d3-4d92-8785-056cae97808d@oracle.com> (raw)
In-Reply-To: <CAADnVQ+GDezR0e+SgqDB5h885Gd500cGYpFs4_LiXpLuD5gYFg@mail.gmail.com>

On 29/05/2025 06:35, Alexei Starovoitov wrote:
> On Wed, May 28, 2025 at 2:58 AM Alan Maguire <alan.maguire@oracle.com> wrote:
>>
>> This allows BTF parsing to proceed even if we do not know the
>> kind.
>>
>> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
>> ---
>>  tools/lib/bpf/btf.c | 35 ++++++++++++++++++++++++++++-------
>>  1 file changed, 28 insertions(+), 7 deletions(-)
>>
>> diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
>> index 43d1fce8977c..7a197dbfc689 100644
>> --- a/tools/lib/bpf/btf.c
>> +++ b/tools/lib/bpf/btf.c
>> @@ -355,7 +355,29 @@ static int btf_parse_kind_layout_sec(struct btf *btf)
>>         return 0;
>>  }
>>
>> -static int btf_type_size(const struct btf_type *t)
>> +/* for unknown kinds, consult kind layout. */
>> +static int btf_type_size_unknown(const struct btf *btf, const struct btf_type *t)
>> +{
>> +       int size = sizeof(struct btf_type);
>> +       struct btf_kind_layout *k = NULL;
>> +       __u16 vlen = btf_vlen(t);
>> +       __u8 kind = btf_kind(t);
>> +
>> +       if (btf->kind_layout)
>> +               k = &((struct btf_kind_layout *)btf->kind_layout)[kind];
>> +
>> +       if (!k || (void *)k > ((void *)btf->kind_layout + btf->hdr->kind_layout_len)) {
>> +               pr_debug("Unsupported BTF_KIND: %u\n", btf_kind(t));
>> +               return -EINVAL;
> 
> I'm missing the point around kind_layout->flags.
> I was expecting that this helper and others at least
> would check that flags == 0, but none of it is happening.
> The patches say that flags is unused and do nothing.
> Why add flags field at all?
>

The intent of the flags field is to provide space to add additional
information about BTF kind encoding that may prove useful. E.g. at time
of encoding for this kind, was the kind flag supported? Perhaps if the
size/type field specifies a type or a size might be another useful flag
setting. But basically the idea is to provide space for additional
information around kind encoding for future use.

So in that context, should we check that flags are 0 now? I'm not sure,
because in some cases we'd like to have older libbpf be able to handle
newer kind layouts which might make use of flags.

>> +       }
>> +
>> +       size += k->info_sz;
>> +       size += vlen * k->elem_sz;
>> +
>> +       return size;
>> +}


  reply	other threads:[~2025-05-29 12:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28  9:57 [PATCH v5 bpf-next 0/9] Add kind layout to BTF Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 1/9] btf: add kind layout encoding to UAPI Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 2/9] libbpf: Support kind layout section handling in BTF Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 3/9] libbpf: use kind layout to compute an unknown kind size Alan Maguire
2025-05-29  5:35   ` Alexei Starovoitov
2025-05-29 12:53     ` Alan Maguire [this message]
2025-05-29 16:30       ` Alexei Starovoitov
2025-05-30 17:20         ` Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 4/9] libbpf: Add kind layout encoding support Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 5/9] libbpf: BTF validation can use kind layout for unknown kinds Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 6/9] btf: support kernel parsing of BTF with kind layout Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 7/9] selftests/bpf: test kind encoding/decoding Alan Maguire
2025-05-28  9:57 ` [PATCH v5 bpf-next 8/9] bpftool: add BTF dump "format meta" to dump header/metadata Alan Maguire
2025-06-03 10:22   ` Quentin Monnet
2025-05-28  9:57 ` [PATCH v5 bpf-next 9/9] kbuild, bpf: Specify "kind_layout" optional feature 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=4cc43d09-50d3-4d92-8785-056cae97808d@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dwarves@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=qmo@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=ttreyer@meta.com \
    --cc=yonghong.song@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.