]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Do not invoke the XDP dispatcher for PROG_RUN with single repeat
authorLorenz Bauer <lmb@cloudflare.com>
Tue, 28 Sep 2021 09:30:59 +0000 (10:30 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Sep 2021 21:10:05 +0000 (14:10 -0700)
commit86ede33b5efa70915675e6c40200b8f93a8a26df
treea62f83fdc7bfe7b37db6455234c9992a31136834
parent677a630c581674d2753b0e4b68b702de2e1634d7
bpf: Do not invoke the XDP dispatcher for PROG_RUN with single repeat

We have a unit test that invokes an XDP program with 1m different
inputs, aka 1m BPF_PROG_RUN syscalls. We run this test concurrently
with slight variations in how we generated the input.

Since commit 40cdea0e9386 ("bpf: Start using the BPF dispatcher in BPF_TEST_RUN")
the unit test has slowed down significantly. Digging deeper reveals that
the concurrent tests are serialised in the kernel on the XDP dispatcher.
This is a global resource that is protected by a mutex, on which we contend.

Fix this by not calling into the XDP dispatcher if we only want to perform
a single run of the BPF program.

See: https://lore.kernel.org/bpf/CACAyw9_y4QumOW35qpgTbLsJ532uGq-kVW-VESJzGyiZkypnvw@mail.gmail.com/

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210928093100.27124-1-lmb@cloudflare.com
net/bpf/test_run.c