From: Kui-Feng Lee <kuifeng@fb.com>
To: "andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>,
"alexei.starovoitov@gmail.com" <alexei.starovoitov@gmail.com>
Cc: "daniel@iogearbox.net" <daniel@iogearbox.net>,
"ast@kernel.org" <ast@kernel.org>,
"andrii@kernel.org" <andrii@kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next v2 3/4] bpf, x86: Support BPF cookie for fentry/fexit/fmod_ret.
Date: Tue, 12 Apr 2022 16:50:32 +0000 [thread overview]
Message-ID: <f3d41f4b31a08d0fac955947f8ed59d1b1bbcd4d.camel@fb.com> (raw)
In-Reply-To: <CAEf4Bzb4d-BT9kVPCAPHmh2nZztx9q+GT4O6ap=HKKNUA3kmKw@mail.gmail.com>
On Mon, 2022-03-21 at 16:37 -0700, Andrii Nakryiko wrote:
> On Mon, Mar 21, 2022 at 4:24 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Fri, Mar 18, 2022 at 12:13 PM Alexei Starovoitov
> > <alexei.starovoitov@gmail.com> wrote:
> > >
> > > On Tue, Mar 15, 2022 at 05:42:30PM -0700, Kui-Feng Lee wrote:
> > > > Add a bpf_cookie field to attach a cookie to an instance of
> > > > struct
> > > > bpf_link. The cookie of a bpf_link will be installed when
> > > > calling the
> > > > associated program to make it available to the program.
> > > >
> > > > Signed-off-by: Kui-Feng Lee <kuifeng@fb.com>
> > > > ---
> > > > arch/x86/net/bpf_jit_comp.c | 4 ++--
> > > > include/linux/bpf.h | 1 +
> > > > include/uapi/linux/bpf.h | 1 +
> > > > kernel/bpf/syscall.c | 11 +++++++----
> > > > kernel/trace/bpf_trace.c | 17 +++++++++++++++++
> > > > tools/include/uapi/linux/bpf.h | 1 +
> > > > tools/lib/bpf/bpf.c | 14 ++++++++++++++
> > > > tools/lib/bpf/bpf.h | 1 +
> > > > tools/lib/bpf/libbpf.map | 1 +
> > > > 9 files changed, 45 insertions(+), 6 deletions(-)
> > >
> > > please split kernel and libbpf changes into two different
> > > patches.
> > >
> >
> > +1
> >
> > > > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> > > > index f69ce3a01385..dbbf09c84c21 100644
> > > > --- a/tools/lib/bpf/bpf.c
> > > > +++ b/tools/lib/bpf/bpf.c
> > > > @@ -1133,6 +1133,20 @@ int bpf_raw_tracepoint_open(const char
> > > > *name, int prog_fd)
> > > > return libbpf_err_errno(fd);
> > > > }
> > > >
> > > > +int bpf_raw_tracepoint_cookie_open(const char *name, int
> > > > prog_fd, __u64 bpf_cookie)
> > >
> > > lets introduce opts style to raw_tp_open instead.
> >
> > I remember I brought this up earlier, but I forgot the outcome.
> > What
> > if don't touch BPF_RAW_TRACEPOINT_OPEN and instead allow to create
> > all
> > the same links through more universal BPF_LINK_CREATE command. And
> > only there we add bpf_cookie? There are few advantages:
> >
> > 1. We can separate raw_tracepoint and trampoline-based programs
> > more
> > cleanly in UAPI (it will be two separate structs:
> > link_create.raw_tp
> > with raw tracepoint name vs link_create.trampoline, or whatever the
> > name, with cookie and stuff). Remember that raw_tp won't support
> > bpf_cookie for now, so it would be another advantage not to promise
> > cookie in UAPI.
> >
> > 2. libbpf can be smart enough to pick either RAW_TRACEPOINT_OPEN
> > (and
> > reject it if bpf_cookie is non-zero) or BPF_LINK_CREATE, depending
> > on
> > kernel support. So users would need to only use bpf_link_create()
> > moving forward with all the backwards compatibility preserved.
> >
> >
>
> Oh, and we need bpf_program__attach_trace_opts() as well (regardless
> of whether it is BPF_RAW_TRACEPOINT_OPEN or BPF_LINK_CREATE).
>
> >
I removed raw_tp_open_opts() since raw_tp won't support bpf_cookie.
Implemented only bpf_program__attach_trace_opts().
next prev parent reply other threads:[~2022-04-12 16:50 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 0:42 [PATCH bpf-next v2 0/4] Attach a cookie to a tracing program Kui-Feng Lee
2022-03-16 0:42 ` [PATCH bpf-next v2 1/4] bpf, x86: Generate trampolines from bpf_links Kui-Feng Lee
2022-03-16 0:42 ` [PATCH bpf-next v2 2/4] bpf, x86: Create bpf_trace_run_ctx on the caller thread's stack Kui-Feng Lee
2022-03-18 19:09 ` Alexei Starovoitov
2022-03-20 9:31 ` Kui-Feng Lee
2022-03-20 20:08 ` Alexei Starovoitov
2022-03-21 19:00 ` Kui-Feng Lee
2022-03-21 23:04 ` Andrii Nakryiko
2022-03-21 23:25 ` Alexei Starovoitov
2022-03-21 23:38 ` Andrii Nakryiko
2022-03-21 23:08 ` Andrii Nakryiko
2022-03-22 15:30 ` Kui-Feng Lee
2022-03-22 21:08 ` Andrii Nakryiko
2022-03-16 0:42 ` [PATCH bpf-next v2 3/4] bpf, x86: Support BPF cookie for fentry/fexit/fmod_ret Kui-Feng Lee
2022-03-18 19:13 ` Alexei Starovoitov
2022-03-21 23:24 ` Andrii Nakryiko
2022-03-21 23:37 ` Andrii Nakryiko
2022-04-12 16:50 ` Kui-Feng Lee [this message]
2022-03-22 1:15 ` Alexei Starovoitov
2022-03-22 4:32 ` Andrii Nakryiko
2022-04-06 5:35 ` Kui-Feng Lee
2022-04-06 17:00 ` Andrii Nakryiko
2022-03-21 23:18 ` Andrii Nakryiko
2022-03-22 16:08 ` Kui-Feng Lee
2022-03-22 21:06 ` Andrii Nakryiko
2022-04-06 22:44 ` Kui-Feng Lee
2022-03-16 0:42 ` [PATCH bpf-next v2 4/4] selftest/bpf: The test cses of " Kui-Feng Lee
2022-03-18 19:21 ` Alexei Starovoitov
2022-03-20 8:43 ` Kui-Feng Lee
2022-03-21 23:29 ` Andrii Nakryiko
2022-03-21 23:36 ` Andrii Nakryiko
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=f3d41f4b31a08d0fac955947f8ed59d1b1bbcd4d.camel@fb.com \
--to=kuifeng@fb.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
/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