From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS
Date: Thu, 26 Mar 2026 17:16:31 -0700 [thread overview]
Message-ID: <44cfca58-e524-43e2-9560-2bfb52d7fb44@linux.dev> (raw)
In-Reply-To: <87tsuajyak.fsf@gmail.com>
On 3/20/26 8:49 AM, Mykyta Yatsenko wrote:
> Ihor Solodrai <ihor.solodrai@linux.dev> writes:
>
>> [...]
>> +/*
>> + * A kfunc with KF_IMPLICIT_ARGS has two prototypes in BTF:
>> + * - the _impl prototype with full arg list (this is meta->func_proto)
>> + * - the BPF API prototype w/o implicit args (func->type in BTF)
>> + * To determine whether an argument is implicit, we compare its position
>> + * against the number of arguments of both prototypes.
>> + */
>> +static bool is_kfunc_arg_implicit(const struct bpf_kfunc_call_arg_meta *meta, u32 arg_idx)
>> +{
>> + const struct btf_type *func, *func_proto;
>> + u32 argn, full_argn;
>> +
>> + if (!(meta->kfunc_flags & KF_IMPLICIT_ARGS))
>> + return false;
>> +
>> + full_argn = btf_type_vlen(meta->func_proto);
>> +
>> + func = btf_type_by_id(meta->btf, meta->func_id);
>> + func_proto = btf_type_by_id(meta->btf, func->type);
>> + argn = btf_type_vlen(func_proto);
>> +
>> + return argn <= arg_idx && arg_idx < full_argn;
> The `arg_idx < full_argn` condition is not necessary, is it?
> arg_idx is always less than full_argn because full_argn is the number of
> arguments in the _impl variant of the function, which is supposed to be
> greater than non-_impl variant that arg_idx tracks.
> arg_idx >= full_argn is an invariant violation, not the implicit
> argument condition, if I understand this right.
Hi Mykyta, thanks for the review.
Yes, I think you're right.
I don't think this helper should error out on arg_idx >= full_argn,
since that would be an error caught in check_kfunc_call(). And returning
an error will make the helper a little more complicated.
At the same time, it seems logical to me that the answer to
"is arg 6 implicit for kfunc with 5 args in _impl proto?"
should be false.
Do you have a specific suggestion?
>
> The rest of the refactoring looks good to me.
>> +}
>> +
>> [...]
>> --
>> 2.53.0
next prev parent reply other threads:[~2026-03-27 0:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 23:42 [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS Ihor Solodrai
2026-03-18 23:42 ` [PATCH bpf-next v3 2/2] selftests/bpf: Update kfuncs using btf_struct_meta to new variants Ihor Solodrai
2026-03-19 12:30 ` Jiri Olsa
2026-03-19 20:43 ` Ihor Solodrai
2026-03-20 11:06 ` Jiri Olsa
2026-03-20 14:50 ` Mykyta Yatsenko
2026-03-19 12:25 ` [PATCH bpf-next v3 1/2] bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS Jiri Olsa
2026-03-19 20:37 ` Ihor Solodrai
2026-03-20 15:49 ` Mykyta Yatsenko
2026-03-27 0:16 ` Ihor Solodrai [this message]
2026-03-27 19:19 ` Mykyta Yatsenko
2026-03-21 20:27 ` Alexei Starovoitov
2026-03-23 19:58 ` Ihor Solodrai
2026-03-24 17:22 ` Alexei Starovoitov
2026-03-26 19:13 ` Ihor Solodrai
2026-03-27 20:48 ` Alexei Starovoitov
2026-03-27 20:55 ` Ihor Solodrai
2026-03-27 21:00 ` Alexei Starovoitov
2026-03-27 21:08 ` Ihor Solodrai
2026-03-27 21:47 ` Alexei Starovoitov
2026-03-27 22:06 ` Ihor Solodrai
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=44cfca58-e524-43e2-9560-2bfb52d7fb44@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=kernel-team@meta.com \
--cc=mykyta.yatsenko5@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