selftests/xsk: load and attach XDP program only once per mode
authorMagnus Karlsson <magnus.karlsson@intel.com>
Wed, 11 Jan 2023 09:35:20 +0000 (10:35 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 12 Jan 2023 02:16:52 +0000 (18:16 -0800)
commitaa61d81f397c65b9951b0da2538657154564564f
tree66248e12be370f3f4d40265c1905dd304ad9b5d1
parent64aef77d750ede548699d81c959936289d7d7819
selftests/xsk: load and attach XDP program only once per mode

Load and attach the XDP program only once per XDP mode that is being
executed. Today, the XDP program is loaded and attached for every
test, then unloaded, which takes a long time on real NICs, since they
have to reconfigure their HW, in contrast to veth. The test suite now
completes in 21 seconds, instead of 207 seconds previously on my
machine. This is a speed-up of around 10x.

This is accomplished by moving the XDP loading from the worker threads
to the main thread and replacing the XDP loading interfaces of xsk.c
that was taken from the xsk support in libbpf, with something more
explicit that is more useful for these tests. Instead, the relevant
file descriptors and ifindexes are just passed down to the new
functions.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20230111093526.11682-10-magnus.karlsson@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/xsk.c
tools/testing/selftests/bpf/xsk.h
tools/testing/selftests/bpf/xskxceiver.c
tools/testing/selftests/bpf/xskxceiver.h