From: Alexei Starovoitov <ast@kernel.org>
To: <davem@davemloft.net>
Cc: <daniel@iogearbox.net>, <x86@kernel.org>,
<netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
<kernel-team@fb.com>
Subject: [PATCH v2 bpf-next 00/17] Introduce BPF trampoline
Date: Wed, 6 Nov 2019 21:46:27 -0800 [thread overview]
Message-ID: <20191107054644.1285697-1-ast@kernel.org> (raw)
Introduce BPF trampoline that works as a bridge between kernel functions, BPF
programs and other BPF programs.
The first use case is fentry/fexit BPF programs that are roughly equivalent to
kprobe/kretprobe. Unlike k[ret]probe there is practically zero overhead to call
a set of BPF programs before or after kernel function.
The second use case is heavily influenced by pain points in XDP development.
BPF trampoline allows attaching similar fentry/fexit BPF program to any
networking BPF program. It's now possible to see packets on input and output of
any XDP, TC, lwt, cgroup programs without disturbing them. This greatly helps
BPF-based network troubleshooting.
The third use case of BPF trampoline will be explored in the follow up patches.
The BPF trampoline will be used to dynamicly link BPF programs. It's more
generic mechanism than array and link list of programs used in tracing,
networking, cgroups. In many cases it can be used as a replacement for
bpf_tail_call-based program chaining.
Goes without saying: all new features are root only.
v1->v2:
- Addressed Andrii's comments
- Added more test for fentry/fexit to kernel functions. Including stress test
for maximum number of progs per trampoline.
- Fixed a race btf_resolve_helper_id()
- Added a patch to compare BTF types of functions arguments with actual types.
- Added support for attaching BPF program to another BPF program via trampoline
- Converted to use text_poke() API. That's the only viable mechanism to
implement BPF-to-BPF attach. BPF-to-kernel attach can be refactored to use
register_ftrace_direct() whenever it's available.
Most of the interesting details are in patches 2,3,13,14.
Alexei Starovoitov (17):
bpf: refactor x86 JIT into helpers
bpf: Add bpf_arch_text_poke() helper
bpf: Introduce BPF trampoline
libbpf: Add support to attach to fentry/fexit tracing progs
selftest/bpf: Simple test for fentry/fexit
bpf: Add kernel test functions for fentry testing
selftests/bpf: Add test for BPF trampoline
selftests/bpf: Add fexit tests for BPF trampoline
selftests/bpf: Add combined fentry/fexit test
selftests/bpf: Add stress test for maximum number of progs
bpf: Reserver space for BPF trampoline in BPF programs
bpf: Fix race in btf_resolve_helper_id()
bpf: Compare BTF types of functions arguments with actual types
bpf: Support attaching tracing BPF program to other BPF programs
selftests/bpf: Extend test_pkt_access test
libbpf: Add support for attaching BPF programs to other BPF programs
selftests/bpf: Add a test for attaching BPF prog to another BPF prog
and subprog
arch/x86/net/bpf_jit_comp.c | 421 +++++++++++++++---
include/linux/bpf.h | 114 ++++-
include/linux/bpf_verifier.h | 2 +
include/linux/btf.h | 1 +
include/uapi/linux/bpf.h | 3 +
kernel/bpf/Makefile | 1 +
kernel/bpf/btf.c | 234 +++++++++-
kernel/bpf/core.c | 9 +
kernel/bpf/syscall.c | 72 ++-
kernel/bpf/trampoline.c | 252 +++++++++++
kernel/bpf/verifier.c | 136 +++++-
kernel/trace/bpf_trace.c | 2 -
net/bpf/test_run.c | 41 ++
tools/include/uapi/linux/bpf.h | 3 +
tools/lib/bpf/bpf.c | 9 +-
tools/lib/bpf/bpf.h | 5 +-
tools/lib/bpf/bpf_helpers.h | 13 +
tools/lib/bpf/libbpf.c | 114 ++++-
tools/lib/bpf/libbpf.h | 8 +-
tools/lib/bpf/libbpf.map | 2 +
.../selftests/bpf/prog_tests/fentry_fexit.c | 90 ++++
.../selftests/bpf/prog_tests/fentry_test.c | 64 +++
.../selftests/bpf/prog_tests/fexit_bpf2bpf.c | 73 +++
.../selftests/bpf/prog_tests/fexit_stress.c | 76 ++++
.../selftests/bpf/prog_tests/fexit_test.c | 64 +++
.../selftests/bpf/prog_tests/kfree_skb.c | 42 +-
.../testing/selftests/bpf/progs/fentry_test.c | 90 ++++
.../selftests/bpf/progs/fexit_bpf2bpf.c | 48 ++
.../testing/selftests/bpf/progs/fexit_test.c | 98 ++++
tools/testing/selftests/bpf/progs/kfree_skb.c | 52 +++
.../selftests/bpf/progs/test_pkt_access.c | 12 +-
31 files changed, 2039 insertions(+), 112 deletions(-)
create mode 100644 kernel/bpf/trampoline.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/fentry_fexit.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/fentry_test.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/fexit_stress.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/fexit_test.c
create mode 100644 tools/testing/selftests/bpf/progs/fentry_test.c
create mode 100644 tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c
create mode 100644 tools/testing/selftests/bpf/progs/fexit_test.c
--
2.23.0
next reply other threads:[~2019-11-07 5:46 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 5:46 Alexei Starovoitov [this message]
2019-11-07 5:46 ` [PATCH v2 bpf-next 01/17] bpf: refactor x86 JIT into helpers Alexei Starovoitov
2019-11-07 17:05 ` Song Liu
2019-11-07 5:46 ` [PATCH v2 bpf-next 02/17] bpf: Add bpf_arch_text_poke() helper Alexei Starovoitov
2019-11-07 17:20 ` Song Liu
2019-11-07 17:50 ` Alexei Starovoitov
2019-11-07 17:54 ` Alexei Starovoitov
2019-11-07 18:04 ` Song Liu
2019-11-07 5:46 ` [PATCH v2 bpf-next 03/17] bpf: Introduce BPF trampoline Alexei Starovoitov
2019-11-07 22:37 ` Song Liu
2019-11-07 22:55 ` Alexei Starovoitov
2019-11-07 23:07 ` Song Liu
2019-11-07 23:09 ` Alexei Starovoitov
2019-11-07 23:16 ` Song Liu
2019-11-08 0:09 ` Alexei Starovoitov
2019-11-08 1:10 ` Song Liu
2019-11-08 3:11 ` Alexei Starovoitov
2019-11-08 4:06 ` Song Liu
2019-11-08 4:08 ` Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 04/17] libbpf: Add support to attach to fentry/fexit tracing progs Alexei Starovoitov
2019-11-07 22:51 ` Song Liu
2019-11-07 23:07 ` Alexei Starovoitov
2019-11-07 23:13 ` Song Liu
2019-11-07 5:46 ` [PATCH v2 bpf-next 05/17] selftest/bpf: Simple test for fentry/fexit Alexei Starovoitov
2019-11-07 23:22 ` Song Liu
2019-11-07 5:46 ` [PATCH v2 bpf-next 06/17] bpf: Add kernel test functions for fentry testing Alexei Starovoitov
2019-11-07 23:28 ` Song Liu
2019-11-07 5:46 ` [PATCH v2 bpf-next 07/17] selftests/bpf: Add test for BPF trampoline Alexei Starovoitov
2019-11-08 1:17 ` Song Liu
2019-11-08 2:33 ` Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 08/17] selftests/bpf: Add fexit tests " Alexei Starovoitov
2019-11-08 1:22 ` Song Liu
2019-11-07 5:46 ` [PATCH v2 bpf-next 09/17] selftests/bpf: Add combined fentry/fexit test Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 10/17] selftests/bpf: Add stress test for maximum number of progs Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 11/17] bpf: Reserver space for BPF trampoline in BPF programs Alexei Starovoitov
2019-11-08 5:03 ` Andrii Nakryiko
2019-11-07 5:46 ` [PATCH v2 bpf-next 12/17] bpf: Fix race in btf_resolve_helper_id() Alexei Starovoitov
2019-11-08 5:13 ` Andrii Nakryiko
2019-11-08 5:31 ` Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 13/17] bpf: Compare BTF types of functions arguments with actual types Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 14/17] bpf: Support attaching tracing BPF program to other BPF programs Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 15/17] selftests/bpf: Extend test_pkt_access test Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 16/17] libbpf: Add support for attaching BPF programs to other BPF programs Alexei Starovoitov
2019-11-07 14:33 ` Alexei Starovoitov
2019-11-07 5:46 ` [PATCH v2 bpf-next 17/17] selftests/bpf: Add a test for attaching BPF prog to another BPF prog and subprog Alexei Starovoitov
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=20191107054644.1285697-1-ast@kernel.org \
--to=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=x86@kernel.org \
/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.