diff options
author | David S. Miller <davem@davemloft.net> | 2015-05-21 23:08:00 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-21 23:08:00 +0200 |
commit | 3f55b7ed5e5d4aa7291e3a1e2f7224eeba5810ba (patch) | |
tree | 632ea9b7f4a1df31760730bf432bae625a4fda8e /drivers/net/ethernet/toshiba/spider_net.c | |
parent | net: dev: reduce both ingress hook ifdefs (diff) | |
parent | samples/bpf: bpf_tail_call example for networking (diff) | |
download | linux-3f55b7ed5e5d4aa7291e3a1e2f7224eeba5810ba.tar.xz linux-3f55b7ed5e5d4aa7291e3a1e2f7224eeba5810ba.zip |
Merge branch 'ebpf-tail-call'
Alexei Starovoitov says:
====================
bpf: introduce bpf_tail_call() helper
introduce bpf_tail_call(ctx, &jmp_table, index) helper function
which can be used from BPF programs like:
int bpf_prog(struct pt_regs *ctx)
{
...
bpf_tail_call(ctx, &jmp_table, index);
...
}
that is roughly equivalent to:
int bpf_prog(struct pt_regs *ctx)
{
...
if (jmp_table[index])
return (*jmp_table[index])(ctx);
...
}
The important detail that it's not a normal call, but a tail call.
The kernel stack is precious, so this helper reuses the current
stack frame and jumps into another BPF program without adding
extra call frame.
It's trivially done in interpreter and a bit trickier in JITs.
Use cases:
- simplify complex programs
- dispatch into other programs
(for example: index in jump table can be syscall number or network protocol)
- build dynamic chains of programs
The chain of tail calls can form unpredictable dynamic loops therefore
tail_call_cnt is used to limit the number of calls and currently is set to 32.
patch 1 - support bpf_tail_call() in interpreter
patch 2 - support in x64 JIT
We've discussed what's neccessary to support it in arm64/s390 JITs
and it looks fine.
patch 3 - sample example for tracing
patch 4 - sample example for networking
More details in every patch.
This set went through several iterations of reviews/fixes and older
attempts can be seen:
https://git.kernel.org/cgit/linux/kernel/git/ast/bpf.git/log/?h=tail_call_v[123456]
- tail_call_v1 does it without touching JITs but introduces overhead
for all programs that don't use this helper function.
- tail_call_v2 still has some overhead and x64 JIT does full stack
unwind (prologue skipping optimization wasn't there)
- tail_call_v3 reuses 'call' instruction encoding and has interpreter
overhead for every normal call
- tail_call_v4 fixes above architectural shortcomings and v5,v6 fix few
more bugs
This last tail_call_v6 approach seems to be the best.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/toshiba/spider_net.c')
0 files changed, 0 insertions, 0 deletions