public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: David Faust <david.faust@oracle.com>
To: Alan Maguire <alan.maguire@oracle.com>,
	ast@kernel.org, yonghong.song@linux.dev
Cc: martin.lau@linux.dev, eddyz87@gmail.com, daniel@iogearbox.net,
	memxor@gmail.com, andrii@kernel.org, song@kernel.org,
	jolsa@kernel.org, qmo@kernel.org, mykyta.yatsenko5@gmail.com,
	bpf@vger.kernel.org
Subject: Re: [PATCH v3 bpf-next 0/6] bpf: Extend BTF UAPI vlen, kinds to use unused bits
Date: Mon, 20 Apr 2026 11:30:09 -0700	[thread overview]
Message-ID: <1b1dd492-316b-4ece-a3f4-dd26d85666fa@oracle.com> (raw)
In-Reply-To: <20260417143023.1551481-1-alan.maguire@oracle.com>



On 4/17/26 07:30, Alan Maguire wrote:
> Currently BTF types can have a maximum of 65535 vlen-specified
> objects.  While this limit has not yet been surpassed for existing
> cases (struct/union fields, enum values, function arguments and
> datasec), upcoming BTF location information - specifically inline
> sites - will hit that limit.  Utilize unused BTF info bits in
> struct btf_type to increase limit to 24-bits (over 16 million).
> This is more than an order of magnitude greater than inline
> site counts for the kernel (~400,000) so should be enough for
> the near future at least.
> 
> Similarly, struct btf_type uses 5 bits for BTF kind values;
> currently we use 20 kinds, but BTF location information will
> take another 3, and conceivably providing better support for Rust
> types in BTF (now that modules can be built using Rust) could
> push us close to the max of 31.  Use 2 unused bits to provide
> a max possible kind of 127.

Should we bump btf_version in the header for this?
(e.g. when emitting from compiler)

It may be useful to know that the BTF for a given file was
constructed with the new limitations like vlen in mind or not.

> 
> Patch 1 handles UAPI and kernel-related changes.
> 
> Patch 2 updates libbpf to have btf_vlen() return a __u32 instead
> of __u16 and updates consumers in libbpf accordingly.  Also adds
> bounds checking for max vlen.
> 
> Patch 3 cleans up __u16 vlen usage in bpftool.
> 
> Patch 4 fixes up a test that relies on BTF info overflowing
> maximum kind value; fix up the expected error to be an
> invalid kind rather than (now impossible) invalid btf_info.
> 
> Patch 5 fixes up __u16 vlen usage in selftests/bpf.
> 
> Patch 6 syncs BTF documentation with UAPI changes.
> 
> Changes since v2 [1]:
> 
> - dropped backwards-compatibility macros (Alexei, patch 1)
> - added additional vlen bounds check in btf__add_field()
>   (sashiko, bpf bot, patch 2)
> - dropped sanitization check in libbpf as older kernels will
>   reject BTF with extended vlen/kinds using BTF info mask
>   (Alexei)
> - fix more vlen assumptions in prog_test/ctx_rewrite.c
>   (sashiko, patch 5)
> 
> Changes since v1 [2]:
> 
> - added redundant macros to UAPI in case enum switch for BTF_MAX*
>   values causes problems (sashiko, patch 1)
> - updated feature test to use BTF loading rather than vmlinux BTF
>   lookup, in line with other BTF feature tests (sashiko, patch 3)
> - fixed up a few more kernel, libbpf, bpftool instances of __u16 usage
>   (bpf bot, sashiko, patches 1, 2, 4)
> - fixed up sanitize selftest cleanup (Mykyta, patch 5)
> - used unlikely-to-be-used kind (sashiko, patch 6)
> - fixed a few lingering selftests uses of __u16 for kind (patch 7)
> - update btf.rst with new vlen, kind sizes (patch 8)
> 
> [1] https://lore.kernel.org/bpf/20260416143904.1220662-1-alan.maguire@oracle.com/
> [2] https://lore.kernel.org/bpf/20260414195019.684531-1-alan.maguire@oracle.com/
> 
> Alan Maguire (6):
>   bpf: Extend BTF UAPI vlen, kinds to use unused bits
>   libbpf: Adjust btf_vlen() to return a __u32
>   bpftool: Support 24-bit vlen
>   selftests/bpf: Fix up btf/invalid test for extended kind
>   selftests/bpf: Fix up __u16 vlen assumptions
>   Documentation/bpf: Update btf doc with updated vlen, kind sizes
> 
>  Documentation/bpf/btf.rst                     |  6 +--
>  include/linux/btf.h                           |  4 +-
>  include/uapi/linux/btf.h                      | 26 +++++-----
>  kernel/bpf/btf.c                              | 27 ++++------
>  tools/bpf/bpftool/btf.c                       | 17 +++----
>  tools/bpf/bpftool/btf_dumper.c                |  4 +-
>  tools/bpf/bpftool/gen.c                       | 16 +++---
>  tools/include/uapi/linux/btf.h                | 26 +++++-----
>  tools/lib/bpf/btf.c                           | 50 ++++++++++++-------
>  tools/lib/bpf/btf.h                           |  2 +-
>  tools/lib/bpf/btf_dump.c                      | 24 ++++-----
>  tools/lib/bpf/relo_core.c                     | 16 +++---
>  tools/testing/selftests/bpf/prog_tests/btf.c  |  8 +--
>  .../bpf/prog_tests/btf_dedup_split.c          |  3 +-
>  .../selftests/bpf/prog_tests/ctx_rewrite.c    |  3 +-
>  tools/testing/selftests/bpf/test_progs.c      |  2 +-
>  16 files changed, 119 insertions(+), 115 deletions(-)
> 


  parent reply	other threads:[~2026-04-20 18:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17 14:30 [PATCH v3 bpf-next 0/6] bpf: Extend BTF UAPI vlen, kinds to use unused bits Alan Maguire
2026-04-17 14:30 ` [PATCH v3 bpf-next 1/6] " Alan Maguire
2026-04-17 18:11   ` Mykyta Yatsenko
2026-04-17 14:30 ` [PATCH v3 bpf-next 2/6] libbpf: Adjust btf_vlen() to return a __u32 Alan Maguire
2026-04-17 17:07   ` sashiko-bot
2026-04-20  8:02     ` Alan Maguire
2026-04-20 15:39       ` Alexei Starovoitov
2026-04-20 16:07         ` Alan Maguire
2026-04-17 18:26   ` Mykyta Yatsenko
2026-04-17 14:30 ` [PATCH v3 bpf-next 3/6] bpftool: Support 24-bit vlen Alan Maguire
2026-04-17 18:36   ` Mykyta Yatsenko
2026-04-17 14:30 ` [PATCH v3 bpf-next 4/6] selftests/bpf: Fix up btf/invalid test for extended kind Alan Maguire
2026-04-17 19:07   ` Mykyta Yatsenko
2026-04-17 14:30 ` [PATCH v3 bpf-next 5/6] selftests/bpf: Fix up __u16 vlen assumptions Alan Maguire
2026-04-17 19:06   ` Mykyta Yatsenko
2026-04-17 14:30 ` [PATCH v3 bpf-next 6/6] Documentation/bpf: Update btf doc with updated vlen, kind sizes Alan Maguire
2026-04-17 15:39   ` bot+bpf-ci
2026-04-20  8:09     ` Alan Maguire
2026-04-20 11:48       ` Mykyta Yatsenko
2026-04-20 18:30 ` David Faust [this message]
2026-04-20 19:24   ` [PATCH v3 bpf-next 0/6] bpf: Extend BTF UAPI vlen, kinds to use unused bits Alan Maguire
2026-04-21  1:00 ` patchwork-bot+netdevbpf

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=1b1dd492-316b-4ece-a3f4-dd26d85666fa@oracle.com \
    --to=david.faust@oracle.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=qmo@kernel.org \
    --cc=song@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox