selftests/xsk: adjust packet pacing for multi-buffer support
authorMagnus Karlsson <magnus.karlsson@intel.com>
Tue, 16 May 2023 10:31:09 +0000 (12:31 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 17 May 2023 05:31:52 +0000 (22:31 -0700)
commit7cd6df4f5ec278888b4c3ab12b291c2124b46c1c
treed88cdfdbcb41f82580ad725bc75976e1bade673e
parent2f6eae0df1a80bb636f43f1b954678da0a10fa49
selftests/xsk: adjust packet pacing for multi-buffer support

Modify the packet pacing algorithm so that it works with multi-buffer
packets. This algorithm makes sure we do not send too many buffers to
the receiving thread so that packets have to be dropped. The previous
algorithm made the assumption that each packet only consumes one
buffer, but that is not true anymore when multi-buffer support gets
added. Instead, we find out what the largest packet size is in the
packet stream and assume that each packet will consume this many
buffers. This is conservative and overly cautious as there might be
smaller packets in the stream that need fewer buffers per packet. But
it keeps the algorithm simple.

Also simplify it by removing the pthread conditional and just test if
there is enough space in the Rx thread before trying to send one more
batch. Also makes the tests run faster.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/r/20230516103109.3066-11-magnus.karlsson@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/xskxceiver.c
tools/testing/selftests/bpf/xskxceiver.h