All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 bpf-next 0/9] Add kind layout to BTF
@ 2025-05-28  9:57 Alan Maguire
  2025-05-28  9:57 ` [PATCH v5 bpf-next 1/9] btf: add kind layout encoding to UAPI Alan Maguire
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Alan Maguire @ 2025-05-28  9:57 UTC (permalink / raw)
  To: andrii, ast
  Cc: daniel, martin.lau, eddyz87, song, yonghong.song, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, masahiroy, qmo, ihor.solodrai,
	dwarves, bpf, ttreyer, Alan Maguire

Update struct btf_header to add a new "kind_layout" section containing
a description of how to parse the BTF kinds known about at BTF
encoding time.  This provides the opportunity for tools that might
not know all of these kinds - as is the case when older tools run
on more newly-generated BTF - to still parse the BTF provided,
even if it cannot all be used.

Also add support to bpftool to dump metadata about BTF; its size,
header information and kind layout section.

The ideas here were discussed at [1], with further discussion
at [2].

Patches for pahole will enable the kind layout addition during
BTF generation are at [3], but even absent these the addition of the
kind_layout feature in the final patch in this series should not break
anything since such unknown features are simply ignored during pahole
BTF generation.

Changes since v4: [4]:

- removed CRC generation since it is not needed to handle modules
  built at different time than kernel; distilled base BTF supports
  this now
- fixed up bpftool display of empty kind names, comment/documentation
  indentation (Quentin, patches 8, 9)

Changes since v3 [5]:

- fixed mismerge issues with kbuild changes for BTF generation
  (patches 9, 14)
- fixed a few small issues in libbpf with kind layout representation
  (patches 2, 4)

Changes since v2 [6]:

- drop "optional" kind flag (Andrii, patch 1)
- allocate "struct btf_header" for struct btf to ensure
  we can always access new fields (Andrii, patch 2)
- use an internal BTF kind array in btf.c to simplify
  kind encoding (Andrii, patch 2)
- drop use of kind layout information for in-kernel parsing,
  since the kernel needs to be strict in what it accepts
  (Andrii, patch 6)
- added CRC verification for BTF objects and for matching
  with base object (Alexei, patches 7,8)
- fixed bpftool json output (Quentin, patch 10)
- added standalone module BTF support, tests (patches 13-17)

Changes since RFC

- Terminology change from meta -> kind_layout
  (Alexei and Andrii)
- Simplify representation, removing meta header
  and just having kind layout section (Alexei)
- Fixed bpftool to have JSON support, support
  prefix match, documented changes (Quentin)
- Separated metadata opts into add_kind_layout
  and add_crc
- Added additional positive/negative tests
  to cover basic unknown kind, one with an
  info_sz object following it and one with
  N elem_sz elements following it.
- Updated pahole-flags to use help output
  rather than version to see if features
  are present


[1] https://lore.kernel.org/bpf/CAEf4BzYjWHRdNNw4B=eOXOs_ONrDwrgX4bn=Nuc1g8JPFC34MA@mail.gmail.com/
[2] https://lore.kernel.org/bpf/20230531201936.1992188-1-alan.maguire@oracle.com/
[3] https://lore.kernel.org/dwarves/20250528095349.788793-1-alan.maguire@oracle.com/
[4] https://lore.kernel.org/bpf/20231112124834.388735-1-alan.maguire@oracle.com/
[5] https://lore.kernel.org/bpf/20231110110304.63910-1-alan.maguire@oracle.com/
[6] https://lore.kernel.org/bpf/20230616171728.530116-1-alan.maguire@oracle.com/


Alan Maguire (9):
  btf: add kind layout encoding to UAPI
  libbpf: Support kind layout section handling in BTF
  libbpf: use kind layout to compute an unknown kind size
  libbpf: Add kind layout encoding support
  libbpf: BTF validation can use kind layout for unknown kinds
  btf: support kernel parsing of BTF with kind layout
  selftests/bpf: test kind encoding/decoding
  bpftool: add BTF dump "format meta" to dump header/metadata
  kbuild, bpf: Specify "kind_layout" optional feature

 include/uapi/linux/btf.h                      |  11 +
 kernel/bpf/btf.c                              |  96 ++++--
 scripts/Makefile.btf                          |   2 +-
 tools/bpf/bpftool/bash-completion/bpftool     |   2 +-
 tools/bpf/bpftool/btf.c                       |  90 ++++-
 tools/include/uapi/linux/btf.h                |  11 +
 tools/lib/bpf/btf.c                           | 316 ++++++++++++++----
 tools/lib/bpf/btf.h                           |  20 ++
 tools/lib/bpf/libbpf.map                      |   1 +
 .../selftests/bpf/prog_tests/btf_kind.c       | 176 ++++++++++
 10 files changed, 627 insertions(+), 98 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/btf_kind.c

-- 
2.39.3


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-06-03 10:22 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.