OSDN Git Service

cgroup/bpf: fast path skb BPF filtering
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 27 Jan 2022 14:09:13 +0000 (14:09 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 27 Jan 2022 18:15:00 +0000 (10:15 -0800)
commit46531a30364bd483bfa1b041c15d42a196e77e93
tree058f81a4a545928c2238696266f2620284982708
parentcdb5ed9796e70ca666863eff65cf4907da5fe13c
cgroup/bpf: fast path skb BPF filtering

Even though there is a static key protecting from overhead from
cgroup-bpf skb filtering when there is nothing attached, in many cases
it's not enough as registering a filter for one type will ruin the fast
path for all others. It's observed in production servers I've looked
at but also in laptops, where registration is done during init by
systemd or something else.

Add a per-socket fast path check guarding from such overhead. This
affects both receive and transmit paths of TCP, UDP and other
protocols. It showed ~1% tx/s improvement in small payload UDP
send benchmarks using a real NIC and in a server environment and the
number jumps to 2-3% for preemtible kernels.

Reviewed-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/r/d8c58857113185a764927a46f4b5a058d36d3ec3.1643292455.git.asml.silence@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf-cgroup.h
include/linux/bpf.h
kernel/bpf/cgroup.c
kernel/bpf/core.c