All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Alexei Starovoitov <ast@kernel.org>,
	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: [PATCH bpf-next v1 0/4] libbpf: Render decl_tags in btf_dump
Date: Wed, 16 Sep 2026 18:20:33 -0700	[thread overview]
Message-ID: <20260917012037.1396254-1-ihor.solodrai@linux.dev> (raw)

BTF supports arbitrary __attribute__ encoding via decl tags and type
tags [1]. However btf_dump facility only outputs the attributes
encoded in BTF as type tags, which was implemented in commit
2019c58318b8 ("libbpf: Check the kflag of type tags in btf_dump").

BTF_KIND_DECL_TAG has been left out of btf_dump entirely, independent
of the kflag value. An attribute a BTF producer encoded is silently
dropped from the C output.

Implement decl_tag support in btf_dump. The btf_dump limits rendered
BTF types to records, record members and typedefs. Other types,
particularly functions, are deliberately skipped. Therefore decl_tag
rendering works only for the same subset of target types.

To be efficient, decl_tag dump support requires a reverse index from
the target type id to the list of tags pointing at it.

With decl_tag dump support, provided a validly constructed BTF, it is
now possible to obtain C-syntax output like the following example:

	struct foo {
		int a __attribute__((bar));
		int b: 3 __attribute__((bar));
	} __attribute__((bar));
	typedef struct { ... } __attribute__((bar)) foo_t __attribute__((baz));

vmlinux.h generated in-tree remains unchanged: every decl tag in
vmlinux BTF is a tag on a FUNC, which is not supported by btf_dump.

[1] https://lore.kernel.org/bpf/20250130201239.1429648-1-ihor.solodrai@linux.dev/

---

The series consists of the following:

  * patch #1 is a non-functional refactoring, preparing
    btf_dump_resize() for decl_tag index build
  * patch #2 implements the full decl_tag dump support
  * patch #3 adds the selftests to cover the new feature
  * patch #4 is an independent selftests change relevant to kflagged
    decl_tag handling

Ihor Solodrai (4):
  libbpf: Walk types in btf_dump_resize(), not in mark_referenced()
  libbpf: Render decl_tags in btf_dump
  selftests/bpf: Test btf_dump rendering of decl_tags
  selftests/bpf: Show the tag kflag in the raw BTF dump helper

 tools/lib/bpf/btf_dump.c                      | 210 ++++++++---
 tools/testing/selftests/bpf/btf_helpers.c     |  10 +-
 .../selftests/bpf/prog_tests/btf_dump.c       | 343 +++++++++++++++++-
 .../selftests/bpf/prog_tests/btf_write.c      |  60 +++
 4 files changed, 560 insertions(+), 63 deletions(-)


base-commit: 10c4f610b215bf961235141161992f010cf7e451
-- 
2.55.0


             reply	other threads:[~2026-09-17  1:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  1:20 Ihor Solodrai [this message]
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
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=20260917012037.1396254-1-ihor.solodrai@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@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 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.