From: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org
Cc: martin.lau@linux.dev, eddyz87@gmail.com, memxor@gmail.com,
song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org,
qmo@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v3 bpf-next 3/6] bpftool: Support 24-bit vlen
Date: Fri, 17 Apr 2026 19:36:28 +0100 [thread overview]
Message-ID: <91343a7a-4820-49fc-9ed0-5638ea74e203@gmail.com> (raw)
In-Reply-To: <20260417143023.1551481-4-alan.maguire@oracle.com>
On 4/17/26 3:30 PM, Alan Maguire wrote:
> Adjust btf_vlen() usage to handle 24-bit vlen.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---
> tools/bpf/bpftool/btf.c | 17 ++++++-----------
> tools/bpf/bpftool/btf_dumper.c | 4 ++--
> tools/bpf/bpftool/gen.c | 16 +++++++++-------
> 3 files changed, 17 insertions(+), 20 deletions(-)
>
> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
> index 2e899e940034..6ef908adf3a4 100644
> --- a/tools/bpf/bpftool/btf.c
> +++ b/tools/bpf/bpftool/btf.c
> @@ -179,8 +179,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
> case BTF_KIND_STRUCT:
> case BTF_KIND_UNION: {
> const struct btf_member *m = (const void *)(t + 1);
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> - int i;
> + __u32 i, vlen = BTF_INFO_VLEN(t->info);
>
> if (json_output) {
> jsonw_uint_field(w, "size", t->size);
> @@ -225,9 +224,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
> }
> case BTF_KIND_ENUM: {
> const struct btf_enum *v = (const void *)(t + 1);
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> + __u32 i, vlen = BTF_INFO_VLEN(t->info);
> const char *encoding;
> - int i;
>
> encoding = btf_kflag(t) ? "SIGNED" : "UNSIGNED";
> if (json_output) {
> @@ -263,9 +261,8 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
> }
> case BTF_KIND_ENUM64: {
> const struct btf_enum64 *v = btf_enum64(t);
> - __u16 vlen = btf_vlen(t);
> + __u32 i, vlen = btf_vlen(t);
> const char *encoding;
> - int i;
>
> encoding = btf_kflag(t) ? "SIGNED" : "UNSIGNED";
> if (json_output) {
> @@ -325,8 +322,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
> }
> case BTF_KIND_FUNC_PROTO: {
> const struct btf_param *p = (const void *)(t + 1);
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> - int i;
> + __u32 i, vlen = BTF_INFO_VLEN(t->info);
>
> if (json_output) {
> jsonw_uint_field(w, "ret_type_id", t->type);
> @@ -369,8 +365,7 @@ static int dump_btf_type(const struct btf *btf, __u32 id,
> case BTF_KIND_DATASEC: {
> const struct btf_var_secinfo *v = (const void *)(t + 1);
> const struct btf_type *vt;
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> - int i;
> + __u32 i, vlen = BTF_INFO_VLEN(t->info);
>
> if (json_output) {
> jsonw_uint_field(w, "size", t->size);
> @@ -675,7 +670,7 @@ static __u64 btf_name_hasher(__u64 hash, const struct btf *btf, __u32 name_off)
> static __u64 btf_type_disambig_hash(const struct btf *btf, __u32 id, bool include_members)
> {
> const struct btf_type *t = btf__type_by_id(btf, id);
> - int i;
> + __u32 i;
in libbpf, kernel and btf_dumper.c we did not migrate those callsites
that use int for vlen, but we do it here. Not an issue, of course,
either way it's correct.
> size_t hash = 0;
>
> hash = btf_name_hasher(hash, btf, t->name_off);
> diff --git a/tools/bpf/bpftool/btf_dumper.c b/tools/bpf/bpftool/btf_dumper.c
> index def297e879f4..9dc8425b1789 100644
> --- a/tools/bpf/bpftool/btf_dumper.c
> +++ b/tools/bpf/bpftool/btf_dumper.c
> @@ -150,7 +150,7 @@ static int btf_dumper_enum(const struct btf_dumper *d,
> {
> const struct btf_enum *enums = btf_enum(t);
> __s64 value;
> - __u16 i;
> + __u32 i;
>
> switch (t->size) {
> case 8:
> @@ -189,7 +189,7 @@ static int btf_dumper_enum64(const struct btf_dumper *d,
> const struct btf_enum64 *enums = btf_enum64(t);
> __u32 val_lo32, val_hi32;
> __u64 value;
> - __u16 i;
> + __u32 i;
>
> value = *(__u64 *)data;
> val_lo32 = (__u32)value;
> diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
> index 2f9e10752e28..37159e02f418 100644
> --- a/tools/bpf/bpftool/gen.c
> +++ b/tools/bpf/bpftool/gen.c
> @@ -2094,7 +2094,8 @@ btfgen_mark_type(struct btfgen_info *info, unsigned int type_id, bool follow_poi
> struct btf_type *cloned_type;
> struct btf_param *param;
> struct btf_array *array;
> - int err, i;
> + __u32 i;
> + int err;
>
> if (type_id == 0)
> return 0;
> @@ -2229,7 +2230,8 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
> const struct btf_type *btf_type;
> struct btf *btf = info->src_btf;
> struct btf_type *cloned_type;
> - int i, err;
> + int err;
> + __u32 i;
>
> if (type_id == 0)
> return 0;
> @@ -2249,7 +2251,7 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
> case BTF_KIND_STRUCT:
> case BTF_KIND_UNION: {
> struct btf_member *m = btf_members(btf_type);
> - __u16 vlen = btf_vlen(btf_type);
> + __u32 vlen = btf_vlen(btf_type);
>
> if (behind_ptr)
> break;
> @@ -2286,7 +2288,7 @@ static int btfgen_mark_type_match(struct btfgen_info *info, __u32 type_id, bool
> break;
> }
> case BTF_KIND_FUNC_PROTO: {
> - __u16 vlen = btf_vlen(btf_type);
> + __u32 vlen = btf_vlen(btf_type);
> struct btf_param *param;
>
> /* mark ret type */
> @@ -2492,8 +2494,9 @@ static struct btf *btfgen_get_btf(struct btfgen_info *info)
> {
> struct btf *btf_new = NULL;
> unsigned int *ids = NULL;
> - unsigned int i, n = btf__type_cnt(info->marked_btf);
> + unsigned int n = btf__type_cnt(info->marked_btf);
> int err = 0;
> + __u32 i;
>
> btf_new = btf__new_empty();
> if (!btf_new) {
> @@ -2523,8 +2526,7 @@ static struct btf *btfgen_get_btf(struct btfgen_info *info)
> /* add members for struct and union */
> if (btf_is_composite(type)) {
> struct btf_member *cloned_m, *m;
> - unsigned short vlen;
> - int idx_src;
> + __u32 vlen, idx_src;
>
> name = btf__str_by_offset(info->src_btf, type->name_off);
>
next prev parent reply other threads:[~2026-04-17 18:36 UTC|newest]
Thread overview: 14+ 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-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 [this message]
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
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=91343a7a-4820-49fc-9ed0-5638ea74e203@gmail.com \
--to=mykyta.yatsenko5@gmail.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=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