Re: [PATCH bpf-next v3 3/6] libbpf: Resolve kfunc variants by prototype
From: Alexei Starovoitov
Date: Fri Dec 04 2026 - 23:39:06 EST
On Thu, Dec 03, 2026 at 08:51 PM Ihor Solodrai <ihor.solodrai@xxxxxxxxx> wrote:
> IMO TL;DR given our prior discussions is that we can accept the
> breakages. An updated (or additional, depending on what kernels BPF
> program tries to cover) kfunc declaration on BPF side fixes them.
Thanks for the analysis.
The breakage is kinda bad.
In the past we beat the drum that libbpf is backward compatible.
Ask Andrii about systemd ...
I don't think we want to repeat that story.
Let's find a way to do it without breaking?
> With this series, such a declaration doesn't resolve on v6.1 to
> v6.10. No single declaration resolves on both sides of v6.11. A
> program that has to run on both sides can declare both prototypes and
> choose in the prog:
bpf_kfuncs.h in v6.6 has 'struct __sk_buff *' and 'struct bpf_dynptr *'
too, and no __weak.
commit cce4c40b9606 changed the kernel side in place. That was safe only
because bpf_core_types_are_compat() accepts any two structs.
v6.1-v6.10 have no variants. There is one candidate and nothing to select.
can we use the struct names only as a tie-break ?
No candidate passes kfunc_type_match() and exactly one passes
bpf_core_types_are_compat(): take that one. libbpf does the same today.
foo(struct a *) next to foo___v1(struct b *) still resolves by the name.
bpf_cpumask_populate() keeps working on both sides too.
> With this series its essential name is scx_bpf_dsq_insert___v2, while
> the kernel's scx_bpf_dsq_insert___v2 is a variant of
> scx_bpf_dsq_insert. So it stays unresolved, and compat.bpf.h falls
> back to scx_bpf_dsq_insert(). Patch 2 makes compat.bpf.h try
> scx_bpf_dsq_insert___v2 first; the scx repo needs the same change.
can we cut the func name at the first ___ instead of the last ?
Then scx_bpf_dsq_insert___v2___compat gets the candidates of
scx_bpf_dsq_insert, and the bool return type selects
scx_bpf_dsq_insert___v2().
The existing scx binaries keep working.
No need for patch 2 and for the change in the scx repo.
I haven't actually tested this idea, but sounds plausible.