From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 2/4] libbpf: Render decl_tags in btf_dump
Date: Wed, 16 Sep 2026 20:25:13 -0700 [thread overview]
Message-ID: <9a3a4128-8a21-4169-8a81-6310bc0d356b@linux.dev> (raw)
In-Reply-To: <DLH87NTSTNKF.1GYVTW5UIE63R@gmail.com>
On 9/16/26 7:12 PM, Alexei Starovoitov wrote:
> On Wed, Sep 16, 2026 at 06:20 PM Ihor Solodrai <ihor.solodrai@linux.dev> wrote:
>> BTF_KIND_DECL_TAG is an attribute on a declaration: with kind_flag=0
>> the tag name is the argument of a btf_decl_tag(), and with kind_flag=1
>> it encodes a complete __attribute__.
>>
>> When doing btf_dump, render both forms at every declaration btf_dump
>> emits - a record, a record member and a typedef:
>
> [...]
>
>> Every decl tag in vmlinux BTF is a bpf_kfunc or bpf_fastcall tag on a
>> FUNC, which has no declaration in the C output, so generated vmlinux.h
>> does not change.
>
> iirc the goal of this series is "bpftool btf dump file prog.bpf.o
> format c" and skeletons growing
> __attribute__((btf_decl_tag("contains:..."))) on members.
> Pls say so in the commit log.
> Otherwise it's 200 lines of code for "generated vmlinux.h doesn't
> change".
Hi Alexei, thank you for quick review.
The decl_tags is an old generic gap in btf_dump, which gets closed
with this patch.
The "contains:" is not the use case I had in mind, but yes, it should
be covered as well. The next thing I planned after this lands is a
bpftool change to get rid of:
#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
in vmlinux.h, by emitting the attributes explicitly per record.
It's been discussed a long time ago, but never picked up on libbpf /
bpftool side [1].
I'll add a paragraph describing potential use cases in v2.
[1] https://lore.kernel.org/bpf/20240503111836.25275-1-jose.marchesi@oracle.com/
>
>> +static int btf_dump_cmp_decl_tags(const void *a, const void *b)
>> +{
>> + const struct decl_tag_desc *x = a, *y = b;
>> +
>> + if (x->target_id != y->tar
> get_id)
>> + return x->target_id < y->target_id ? -1 : 1;
>> + return x->tag_id < y->tag_id ? -1 : 1;
>> +}
>
> nit: return 0 when equal. cmp(x, x) != 0 is asking for trouble.
For a valid deduped BTF we should never get a duplicate (target_id,
tag_id) pair. I'll see if there is a way to detect this and -EINVAL
>
>> @@ -220,8 +258,18 @@ static int btf_dump_resize(struct btf_dump *d)
>> err = btf_dump_mark_referenced(d, t);
>> if (err)
>> return err;
>> +
>> + if (btf_is_decl_tag(t)) {
>> + err = btf_dump_push_decl_tag(d, i, t);
>> + if (err)
>> + return err;
>> + }
>> }
>
> \edited robot voice
>
> On either error d->last_id is not advanced but d->decl_tags_cnt keeps
> whatever was pushed so far, so the next btf_dump__dump_type() walks
> the same ids again and pushes the same tags twice -> duplicated
> __attribute__ in the output ?
Yeah, my clanker flagged this too. I decided a mid-dump retry on error
is a weird case to support in the context of btf_dump, so ignored it.
Andrii, do you have an opinion?
>
> pw-bot: cr
next prev parent reply other threads:[~2026-09-17 3:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 1:20 [PATCH bpf-next v1 0/4] libbpf: Render decl_tags in btf_dump Ihor Solodrai
2026-09-17 1:20 ` [PATCH bpf-next v1 1/4] libbpf: Walk types in btf_dump_resize(), not in mark_referenced() Ihor Solodrai
2026-09-17 22:32 ` Eduard Zingerman
2026-09-17 1:20 ` [PATCH bpf-next v1 2/4] libbpf: Render decl_tags in btf_dump Ihor Solodrai
2026-09-17 1:30 ` sashiko-bot
2026-09-17 2:12 ` Alexei Starovoitov
2026-09-17 3:25 ` Ihor Solodrai [this message]
2026-09-17 22:46 ` Eduard Zingerman
2026-09-17 23:59 ` Andrii Nakryiko
2026-09-22 16:59 ` Ihor Solodrai
2026-09-22 19:43 ` Andrii Nakryiko
2026-09-17 1:20 ` [PATCH bpf-next v1 3/4] selftests/bpf: Test btf_dump rendering of decl_tags Ihor Solodrai
2026-09-17 10:30 ` Alan Maguire
2026-09-17 17:38 ` Ihor Solodrai
2026-09-17 23:18 ` Eduard Zingerman
2026-09-17 1:20 ` [PATCH bpf-next v1 4/4] selftests/bpf: Show the tag kflag in the raw BTF dump helper Ihor Solodrai
2026-09-17 1:27 ` sashiko-bot
2026-09-17 23:21 ` Eduard Zingerman
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=9a3a4128-8a21-4169-8a81-6310bc0d356b@linux.dev \
--to=ihor.solodrai@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.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