From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>
Subject: [RFC PATCH bpf-next 00/17] bpf: Add tracing multi link
Date: Mon, 8 Aug 2022 16:06:09 +0200 [thread overview]
Message-ID: <20220808140626.422731-1-jolsa@kernel.org> (raw)
hi,
this is another attempt to add batch attachment support for
trampolines.
The patchset adds support to create 'multi' trampoline that is
attached to set of functions represented by BTF IDs.
Previous post [0] tried to implement multi trampolines overlapping,
but it turned out too complex, so I got back to simpler rules:
(we can discuss possible overlapping changes on top this change)
- multi trampoline can attach on top of existing single trampolines,
which creates 2 types of function IDs:
1) single-IDs - functions that are attached within existing
single trampolines
2) multi-IDs - functions that were 'not used' and are now
taken by new 'multi' trampoline
- we allow overlapping of 2 'multi' trampolines if they are attached
to same IDs
- we do now allow any other overlapping of 2 'multi' trampolines
- any new 'single' trampoline cannot attach to existing multi-IDs IDs
Maybe better explained on following example:
- you want to attach program P to functions A,B,C,D,E,F
via bpf_trampoline_multi_attach
- D,E,F already have standard trampoline attached
- the bpf_trampoline_multi_attach will create new 'multi' trampoline
which spans over A,B,C functions and attach program P to single
trampolines D,E,F
- another program can be attached to A,B,C,D,E,F multi trampoline
- A,B,C functions are now 'not attachable' by any trampoline
until the above 'multi' trampoline is released
- D,E,F functions are still attachable by any new trampoline
Also now that we have trampoline helpers for function arguments,
we can just simply use function declaration with maximum arguments
for any multi trampoline or related single trampoline.
There are couple of things missing in this post (that I know of),
which I'll add when we agree that this is the way to go:
- attaching by functions names
- cookies support
- find out better way of locking trampolines in bpf_trampoline_multi_attach
and bpf_trampoline_multi_detach
- bpf_tramp_update_set logic of calling multiple times register_ftrace_direct_multi
function can be replaced by calling single update ftrace function that I have
prototype for, but I will send it out separately to ftrace for review
- arm trampoline code changes (won't compile now)
- tests for error paths
thanks,
jirka
[0] - https://lore.kernel.org/bpf/20211118112455.475349-1-jolsa@kernel.org/
---
Jiri Olsa (17):
bpf: Link shimlink directly in trampoline
bpf: Replace bpf_tramp_links with bpf_tramp_progs
bpf: Store trampoline progs in arrays
bpf: Add multi tracing attach types
bpf: Add bpf_tramp_id object
bpf: Pass image struct to reg/unreg/modify fentry functions
bpf: Add support to postpone trampoline update
bpf: Factor bpf_trampoline_lookup function
bpf: Factor bpf_trampoline_put function
bpf: Add support to attach program to multiple trampolines
bpf: Add support to create tracing multi link
libbpf: Add btf__find_by_glob_kind function
libbpf: Add support to create tracing multi link
selftests/bpf: Add fentry tracing multi func test
selftests/bpf: Add fexit tracing multi func test
selftests/bpf: Add fentry/fexit tracing multi func test
selftests/bpf: Add mixed tracing multi func test
arch/x86/net/bpf_jit_comp.c | 38 ++---
include/linux/bpf.h | 98 ++++++++----
include/linux/trace_events.h | 5 +
include/uapi/linux/bpf.h | 7 +
kernel/bpf/bpf_struct_ops.c | 30 ++--
kernel/bpf/syscall.c | 56 +++++--
kernel/bpf/trampoline.c | 723 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
kernel/bpf/verifier.c | 8 +-
kernel/trace/bpf_trace.c | 240 +++++++++++++++++++++++++++++
net/bpf/bpf_dummy_struct_ops.c | 16 +-
net/bpf/test_run.c | 2 +
tools/include/uapi/linux/bpf.h | 7 +
tools/lib/bpf/bpf.c | 7 +
tools/lib/bpf/bpf.h | 4 +
tools/lib/bpf/btf.c | 41 +++++
tools/lib/bpf/btf.h | 3 +
tools/lib/bpf/libbpf.c | 91 ++++++++++-
tools/lib/bpf/libbpf.h | 14 ++
tools/lib/bpf/libbpf.map | 1 +
tools/lib/bpf/libbpf_internal.h | 1 +
tools/testing/selftests/bpf/Makefile | 9 +-
tools/testing/selftests/bpf/prog_tests/tracing_multi.c | 158 ++++++++++++++++++++
tools/testing/selftests/bpf/progs/tracing_multi_check.c | 158 ++++++++++++++++++++
tools/testing/selftests/bpf/progs/tracing_multi_fentry.c | 17 +++
tools/testing/selftests/bpf/progs/tracing_multi_fentry_fexit.c | 28 ++++
tools/testing/selftests/bpf/progs/tracing_multi_fexit.c | 20 +++
tools/testing/selftests/bpf/progs/tracing_multi_mixed.c | 43 ++++++
27 files changed, 1624 insertions(+), 201 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/tracing_multi.c
create mode 100644 tools/testing/selftests/bpf/progs/tracing_multi_check.c
create mode 100644 tools/testing/selftests/bpf/progs/tracing_multi_fentry.c
create mode 100644 tools/testing/selftests/bpf/progs/tracing_multi_fentry_fexit.c
create mode 100644 tools/testing/selftests/bpf/progs/tracing_multi_fexit.c
create mode 100644 tools/testing/selftests/bpf/progs/tracing_multi_mixed.c
next reply other threads:[~2022-08-08 14:06 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-08 14:06 Jiri Olsa [this message]
2022-08-08 14:06 ` [RFC PATCH bpf-next 01/17] bpf: Link shimlink directly in trampoline Jiri Olsa
2022-08-08 17:40 ` Song Liu
2022-08-08 17:58 ` Stanislav Fomichev
2022-08-09 15:36 ` Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 02/17] bpf: Replace bpf_tramp_links with bpf_tramp_progs Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 03/17] bpf: Store trampoline progs in arrays Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 04/17] bpf: Add multi tracing attach types Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 05/17] bpf: Add bpf_tramp_id object Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 06/17] bpf: Pass image struct to reg/unreg/modify fentry functions Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 07/17] bpf: Add support to postpone trampoline update Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 08/17] bpf: Factor bpf_trampoline_lookup function Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 09/17] bpf: Factor bpf_trampoline_put function Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 10/17] bpf: Add support to attach program to multiple trampolines Jiri Olsa
2022-08-24 1:22 ` Alexei Starovoitov
2022-08-25 16:08 ` Jiri Olsa
2022-08-25 17:43 ` Alexei Starovoitov
2022-08-26 2:35 ` Andrii Nakryiko
2022-08-26 14:20 ` Jiri Olsa
2022-08-27 5:15 ` Andrii Nakryiko
2022-08-27 12:16 ` Jiri Olsa
2022-08-26 4:37 ` Song Liu
2022-08-08 14:06 ` [RFC PATCH bpf-next 11/17] bpf: Add support to create tracing multi link Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 12/17] libbpf: Add btf__find_by_glob_kind function Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 13/17] libbpf: Add support to create tracing multi link Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 14/17] selftests/bpf: Add fentry tracing multi func test Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 15/17] selftests/bpf: Add fexit " Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 16/17] selftests/bpf: Add fentry/fexit " Jiri Olsa
2022-08-08 14:06 ` [RFC PATCH bpf-next 17/17] selftests/bpf: Add mixed " Jiri Olsa
2022-08-08 17:50 ` [RFC PATCH bpf-next 00/17] bpf: Add tracing multi link Song Liu
2022-08-08 20:35 ` Jiri Olsa
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=20220808140626.422731-1-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox