]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Introduce BPF dispatcher
authorBjörn Töpel <bjorn.topel@intel.com>
Fri, 13 Dec 2019 17:51:08 +0000 (18:51 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 Dec 2019 21:09:32 +0000 (13:09 -0800)
commitb62b6d833d3a233af87d61e6ad7deb05fcfdbf39
treec1d92822ed470de368dfe5a102af694ffb1ee7e3
parent7390f08c24883795d4439e7f9eae357de918a0c9
bpf: Introduce BPF dispatcher

The BPF dispatcher is a multi-way branch code generator, mainly
targeted for XDP programs. When an XDP program is executed via the
bpf_prog_run_xdp(), it is invoked via an indirect call. The indirect
call has a substantial performance impact, when retpolines are
enabled. The dispatcher transform indirect calls to direct calls, and
therefore avoids the retpoline. The dispatcher is generated using the
BPF JIT, and relies on text poking provided by bpf_arch_text_poke().

The dispatcher hijacks a trampoline function it via the __fentry__ nop
of the trampoline. One dispatcher instance currently supports up to 64
dispatch points. A user creates a dispatcher with its corresponding
trampoline with the DEFINE_BPF_DISPATCHER macro.

Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191213175112.30208-3-bjorn.topel@gmail.com
arch/x86/net/bpf_jit_comp.c
include/linux/bpf.h
kernel/bpf/Makefile
kernel/bpf/dispatcher.c [new file with mode: 0644]