BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"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: Thu, 17 Sep 2026 02:12:45 +0000	[thread overview]
Message-ID: <DLH87NTSTNKF.1GYVTW5UIE63R@gmail.com> (raw)
In-Reply-To: <20260917012037.1396254-3-ihor.solodrai@linux.dev>

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".

> +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.

> @@ -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 ?

pw-bot: cr

  parent reply	other threads:[~2026-09-17  2:12 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 [this message]
2026-09-17  3:25     ` Ihor Solodrai
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=DLH87NTSTNKF.1GYVTW5UIE63R@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=ihor.solodrai@linux.dev \
    --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