Re: [PATCH bpf-next v1 0/4] libbpf: Support kernel-side kfunc flavors

From: Eduard Zingerman

Date: Wed Nov 18 2026 - 16:58:16 EST


On Wed, 2026-11-18 at 14:48 -0700, Ihor Solodrai wrote:
> On 2026-11-18 2:42 p.m., Eduard Zingerman wrote:
> > On Wed, 2026-11-18 at 14:12 -0700, Eduard Zingerman wrote:
> > > On Tue, 2026-11-17 at 12:21 -0700, Ihor Solodrai wrote:
> >
> > ...
> >
> > > > resolve_btfids fails the build if two of bpf_foo and its flavors have
> > > > compatible prototypes, unless both have foo's exact prototype
> > > > (aliases), so the fallback finds at most one match.  This ensures at
> > >
> > > Why is an exception for kfuncs with identical prototypes necessary?
> >
> > Ok, my helpful assistant points out the following use case:
> >
> > On kernel side:
> >
> >    __bpf_kfunc bool foo(struct task_struct *p, u64 flags);
> >    __bpf_kfunc bool foo___v2(struct task_struct *p, u64 flags);
> >
> >
> > On BPF side:
> >
> >
> >    extern bool foo(struct task_struct *p, u64 flags) __ksym;
> >    extern bool foo___v2___compat(struct task_struct *p, u64 flags) __ksym;
> >
> >    /* Resolves to the kernel's foo(). */
> >    foo(p, 0);
> >
> >    /* libbpf strips ___compat; resolves to the kernel's foo___v2().
> >     * workaround used before this series.
> >     */
> >    foo___v2___compat(p, 0);
> >
> > New mechanics adds an obligation on the kernel side to maintain that
> > foo and foo___v2___compat are semantically identical, despite being
> > physically different functions. (Does it?)
>
> Yes. I just replied with exactly same example (it's used in sched-ext).
>
> >
> > Would it be possible to use some kind of annotation, e.g.:
> > - __alias(foo___v2) (an ELF symbol alias), or
> > - __kfunc_alias(foo___v2)
> >    (resolving to some sort of btf_decl_tag for resolve_btfids to act upon).
> > And avoid allowing functions with compatible prototypes w/o exceptions.
> >
> > ?
>
> My intuition is that it's possible, but it'd be more complicated.
> The question is why?

Is it a requirement now for foo() and foo___v2___compat()
to be semantically identical? If it is, the alias mechanics forgoes
this requirement.

> libbpf side might become marginally simpler, but we'd add complexity
> on the kernel side, no?

On kernel side or on resolve_btfids side?