All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf@google.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>, "Yonghong Song" <yhs@fb.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>, "Hao Luo" <haoluo@google.com>,
	"Jiri Olsa" <jolsa@kernel.org>, bpf <bpf@vger.kernel.org>,
	"David Vernet" <void@manifault.com>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>
Subject: Re: [RFC PATCH v2] Documentation/bpf: Add a description of "stable kfuncs"
Date: Tue, 17 Jan 2023 18:00:58 -0800	[thread overview]
Message-ID: <CAKH8qBvZgoOe24MMY+Jn-6guJzGVuJS9zW4v6H+fhgcp7X_9jQ@mail.gmail.com> (raw)
In-Reply-To: <CAADnVQKy1QzM+wg1BxfYA30QsTaM4M5RRCi+VHN6A7ah2BeZZw@mail.gmail.com>

On Tue, Jan 17, 2023 at 3:19 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Jan 17, 2023 at 2:20 PM Stanislav Fomichev <sdf@google.com> wrote:
> >
> > On Tue, Jan 17, 2023 at 2:04 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> > >
> > > Stanislav Fomichev <sdf@google.com> writes:
> > >
> > > > On Tue, Jan 17, 2023 at 1:27 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> > > >>
> > > >> Following up on the discussion at the BPF office hours, this patch adds a
> > > >> description of the (new) concept of "stable kfuncs", which are kfuncs that
> > > >> offer a "more stable" interface than what we have now, but is still not
> > > >> part of UAPI.
> > > >>
> > > >> This is mostly meant as a straw man proposal to focus discussions around
> > > >> stability guarantees. From the discussion, it seemed clear that there were
> > > >> at least some people (myself included) who felt that there needs to be some
> > > >> way to export functionality that we consider "stable" (in the sense of
> > > >> "applications can rely on its continuing existence").
> > > >>
> > > >> One option is to keep BPF helpers as the stable interface and implement
> > > >> some technical solution for moving functionality from kfuncs to helpers
> > > >> once it has stood the test of time and we're comfortable committing to it
> > > >> as a stable API. Another is to freeze the helper definitions, and instead
> > > >> use kfuncs for this purpose as well, by marking a subset of them as
> > > >> "stable" in some way. Or we can do both and have multiple levels of
> > > >> "stable", I suppose.
> > > >>
> > > >> This patch is an attempt to describe what the "stable kfuncs" idea might
> > > >> look like, as well as to formulate some criteria for what we mean by
> > > >> "stable", and describe an explicit deprecation procedure. Feel free to
> > > >> critique any part of this (including rejecting the notion entirely).
> > > >>
> > > >> Some people mentioned (in the office hours) that should we decide to go in
> > > >> this direction, there's some work that needs to be done in libbpf (and
> > > >> probably the kernel too?) to bring the kfunc developer experience up to par
> > > >> with helpers. Things like exporting kfunc definitions to vmlinux.h (to make
> > > >> them discoverable), and having CO-RE support for using them, etc. I kinda
> > > >> consider that orthogonal to what's described here, but I do think we should
> > > >> fix those issues before implementing the procedures described here.
> > > >>
> > > >> v2:
> > > >> - Incorporate Daniel's changes
> > > >>
> > > >> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> > > >> ---
> > > >>  Documentation/bpf/kfuncs.rst | 87 +++++++++++++++++++++++++++++++++---
> > > >>  1 file changed, 81 insertions(+), 6 deletions(-)
> > > >>
> > > >> diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
> > > >> index 9fd7fb539f85..dd40a4ee35f2 100644
> > > >> --- a/Documentation/bpf/kfuncs.rst
> > > >> +++ b/Documentation/bpf/kfuncs.rst
> > > >> @@ -7,9 +7,9 @@ BPF Kernel Functions (kfuncs)
> > > >>
> > > >>  BPF Kernel Functions or more commonly known as kfuncs are functions in the Linux
> > > >>  kernel which are exposed for use by BPF programs. Unlike normal BPF helpers,
> > > >> -kfuncs do not have a stable interface and can change from one kernel release to
> > > >> -another. Hence, BPF programs need to be updated in response to changes in the
> > > >> -kernel.
> > > >> +kfuncs by default do not have a stable interface and can change from one kernel
> > > >> +release to another. Hence, BPF programs may need to be updated in response to
> > > >> +changes in the kernel. See :ref:`BPF_kfunc_stability`.
> > > >>
> > > >>  2. Defining a kfunc
> > > >>  ===================
> > > >> @@ -223,14 +223,89 @@ type. An example is shown below::
> > > >>          }
> > > >>          late_initcall(init_subsystem);
> > > >>
> > > >> -3. Core kfuncs
> > > >> +
> > > >> +.. _BPF_kfunc_stability:
> > > >> +
> > > >> +3. API (in)stability of kfuncs
> > > >> +==============================
> > > >> +
> > > >> +By default, kfuncs exported to BPF programs are considered a kernel-internal
> > > >> +interface that can change between kernel versions. This means that BPF programs
> > > >> +using kfuncs may need to adapt to changes between kernel versions. In the
> > > >> +extreme case that could also include removal of a kfunc. In other words, kfuncs
> > > >> +are _not_ part of the kernel UAPI! Rather, these kfuncs can be thought of as
> > > >> +being similar to internal kernel API functions exported using the
> > > >
> > > > [..]
> > > >
> > > >> +``EXPORT_SYMBOL_GPL`` macro. All new BPF kernel helper-like functionality must
> > > >> +initially start out as kfuncs.
> > > >
> > > > To clarify, as part of this proposal, are we making a decision here
> > > > that we ban new helpers going forward?
> > >
> > > Good question! That is one of the things I'm hoping we can clear up by
> > > this discussing. I don't have a strong opinion on the matter myself, as
> > > long as there is *some* way to mark a subset of helpers/kfuncs as
> > > "stable"...
> >
> > Might be worth it to capitalize in this case to indicate that it's a
> > MUST from the RFC world? (or go with SHOULD otherwise).
> > I'm fine either way. The only thing that stops me from fully embracing
> > MUST is the kfunc requirement on the explicit jit support; I'm not
> > sure why it exists and at this point I'm too afraid to ask. But having
> > MUST here might give us motivation to address the shortcomings...
>
> Did you do:
> git grep bpf_jit_supports_kfunc_call
> and didn't find your favorite architecture there and
> didn't find it in the upcoming patches for riscv and arm32?
> If you care about kfuncs on arm32 please help reviewing posted patches.

Exactly why I'm going to support whatever decision is being made here.
Just trying to clarify what that decision is.

  reply	other threads:[~2023-01-18  2:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 21:27 [RFC PATCH v2] Documentation/bpf: Add a description of "stable kfuncs" Toke Høiland-Jørgensen
2023-01-17 21:53 ` Stanislav Fomichev
2023-01-17 22:03   ` Toke Høiland-Jørgensen
2023-01-17 22:20     ` Stanislav Fomichev
2023-01-17 23:19       ` Alexei Starovoitov
2023-01-18  2:00         ` Stanislav Fomichev [this message]
2023-01-18 10:48           ` Daniel Borkmann
2023-01-18 16:53             ` David Vernet
2023-01-19  4:32             ` Alexei Starovoitov
2023-01-24 17:17               ` Andrii Nakryiko
2023-01-24 19:54                 ` Andrii Nakryiko
2023-01-25  1:18               ` Toke Høiland-Jørgensen
2023-01-26  5:34                 ` Alexei Starovoitov
2023-01-27 17:50                   ` Toke Høiland-Jørgensen
2023-01-18 15:53 ` David Vernet

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=CAKH8qBvZgoOe24MMY+Jn-6guJzGVuJS9zW4v6H+fhgcp7X_9jQ@mail.gmail.com \
    --to=sdf@google.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=song@kernel.org \
    --cc=toke@redhat.com \
    --cc=void@manifault.com \
    --cc=yhs@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.