BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: "Alan Maguire" <alan.maguire@oracle.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Jiri Olsa" <jolsa@kernel.org>, "Song Liu" <song@kernel.org>,
	"Tejun Heo" <tj@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>, <bpf@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <sched-ext@lists.linux.dev>
Subject: Re: [PATCH bpf-next v3 3/6] libbpf: Resolve kfunc variants by prototype
Date: Sat, 05 Dec 2026 04:38:57 +0000	[thread overview]
Message-ID: <DNCISMX8XG7N.2D5929H777Y2E@gmail.com> (raw)
In-Reply-To: <fe08250b-fd33-4bca-91de-f5307da63e01@linux.dev>

On Thu, Dec 03, 2026 at 08:51 PM Ihor Solodrai <ihor.solodrai@linux.dev> 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.


  reply	other threads:[~2026-12-05  4:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 22:48 [PATCH bpf-next v3 0/6] libbpf: Support kernel-side kfunc variants Ihor Solodrai
2026-11-24 22:48 ` [PATCH bpf-next v3 1/6] libbpf: Separate interfaces shared with in-tree tools Ihor Solodrai
2026-11-24 22:50   ` Ihor Solodrai
2026-11-24 22:53     ` Andrii Nakryiko
2026-11-24 23:40   ` bot+bpf-ci
2026-11-24 22:48 ` [PATCH bpf-next v3 2/6] sched_ext: Prefer ___v2 kfunc names in compat.bpf.h Ihor Solodrai
2026-11-24 22:48 ` [PATCH bpf-next v3 3/6] libbpf: Resolve kfunc variants by prototype Ihor Solodrai
2026-11-24 23:40   ` bot+bpf-ci
2026-11-25  1:22   ` Andrii Nakryiko
2026-11-25 20:28   ` Eduard Zingerman
2026-12-04  4:51     ` Ihor Solodrai
2026-12-05  4:38       ` Alexei Starovoitov [this message]
2026-11-24 22:48 ` [PATCH bpf-next v3 4/6] selftests/bpf: Test kfunc variant selection " Ihor Solodrai
2026-11-24 22:48 ` [PATCH bpf-next v3 5/6] resolve_btfids: Reject ambiguous kfunc variants Ihor Solodrai
2026-11-24 22:48 ` [PATCH bpf-next v3 6/6] docs/bpf: Describe how to change a kfunc's prototype 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=DNCISMX8XG7N.2D5929H777Y2E@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=sched-ext@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=tj@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