mbox series

[bpf-next,v3,00/15] selftests/xsk: speed-ups, fixes, and new XDP programs

Message ID 20230111093526.11682-1-magnus.karlsson@gmail.com (mailing list archive)
Headers show
Series selftests/xsk: speed-ups, fixes, and new XDP programs | expand

Message

Magnus Karlsson Jan. 11, 2023, 9:35 a.m. UTC
This is a patch set of various performance improvements, fixes, and
the introduction of more than one XDP program to the xsk selftests
framework so we can test more things in the future such as upcoming
multi-buffer and metadata support for AF_XDP. The new programs just
reuse the framework that all the other eBPF selftests use. The new
feature is used to implement one new test that does XDP_DROP on every
other packet. More tests using this will be added in future commits.

Contents:

* The run-time of the test suite is cut by 10x when executing the
  tests on a real NIC, by only attaching the XDP program once per mode
  tested, instead of once per test program.

* Over 700 lines of code have been removed. The xsk.c control file was
  moved straight over from libbpf when the xsk support was deprecated
  there. As it is now not used as library code that has to work with
  all kinds of versions of Linux, a lot of code could be dropped or
  simplified.

* Add a new command line option "-d" that can be used when a test
  fails and you want to debug it with gdb or some other debugger. The
  option creates the two veth netdevs and prints them to the screen
  without deleting them afterwards. This way these veth netdevs can be
  used when running xskxceiver in a debugger.

* Implemented the possibility to load external XDP programs so we can
  have more than the default one. This feature is used to implement a
  test where every other packet is dropped. Good exercise for the
  recycling mechanism of the xsk buffer pool used in zero-copy mode.

* Various clean-ups and small fixes in patches 1 to 5. None of these
  fixes has any impact on the correct execution of the tests when they
  pass, though they can be irritating when a test fails. IMHO, they do
  not need to go to bpf as they will not fix anything there. The first
  version of patches 1, 2, and 4 where previously sent to bpf, but has
  now been included here.

v2 -> v3:
* Fixed compilation error for llvm [David]
* Made the function xsk_is_in_drv_mode(ifobj) more generic by changing
  it to xsk_is_in_mode(ifobj, xdp_mode) [Maciej]
* Added Maciej's acks to all the patches

v1 -> v2:
* Fixed spelling error in commit message of patch #6 [Björn]
* Added explanation on why it is safe to use C11 atomics in patch #7
  [Daniel]
* Put all XDP programs in the same file so that adding more XDP
  programs to xskxceiver.c becomes more scalable in patches #11 and
  #12 [Maciej]
* Removed more dead code in patch #8 [Maciej]
* Removed stale %s specifier in error print, patch #9 [Maciej]
* Changed name of XDP_CONSUMES_SOME_PACKETS to XDP_DROP_HALF to
  hopefully make it clearer [Maciej]
* ifobj_rx and ifobj_tx name changes in patch #13 [Maciej]
* Simplified XDP attachment code in patch #15 [Maciej]

Patches:
1-5:   Small fixes and clean-ups
6:     New convenient debug option when using a debugger such as gdb
7-8:   Removal of unnecessary code
9:     Add the ability to load external XDP programs
10-11: Removal of more unnecessary code
12:    Implement a new test where every other packet is XDP_DROP:ed
13:    Unify the thread dispatching code
14-15: Simplify the way tests are written when using custom packet_streams
       or custom XDP programs

Thanks: Magnus

Magnus Karlsson (15):
  selftests/xsk: print correct payload for packet dump
  selftests/xsk: do not close unused file descriptors
  selftests/xsk: submit correct number of frames in populate_fill_ring
  selftests/xsk: print correct error codes when exiting
  selftests/xsk: remove unused variable outstanding_tx
  selftests/xsk: add debug option for creating netdevs
  selftests/xsk: replace asm acquire/release implementations
  selftests/xsk: remove namespaces
  selftests/xsk: load and attach XDP program only once per mode
  selftests/xsk: remove unnecessary code in control path
  selftests/xsk: get rid of built-in XDP program
  selftests/xsk: add test when some packets are XDP_DROPed
  selftests/xsk: merge dual and single thread dispatchers
  selftests/xsk: automatically restore packet stream
  selftests/xsk: automatically switch XDP programs

 tools/testing/selftests/bpf/Makefile          |   6 +-
 .../selftests/bpf/progs/xsk_xdp_progs.c       |  30 +
 tools/testing/selftests/bpf/test_xsk.sh       |  42 +-
 tools/testing/selftests/bpf/xsk.c             | 677 +-----------------
 tools/testing/selftests/bpf/xsk.h             |  97 +--
 tools/testing/selftests/bpf/xsk_prereqs.sh    |  12 +-
 tools/testing/selftests/bpf/xskxceiver.c      | 382 +++++-----
 tools/testing/selftests/bpf/xskxceiver.h      |  17 +-
 8 files changed, 316 insertions(+), 947 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/xsk_xdp_progs.c


base-commit: 6920b08661e3ad829206078b5c9879b24aea8dfc
--
2.34.1

Comments

patchwork-bot+netdevbpf@kernel.org Jan. 12, 2023, 2:30 a.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Wed, 11 Jan 2023 10:35:11 +0100 you wrote:
> This is a patch set of various performance improvements, fixes, and
> the introduction of more than one XDP program to the xsk selftests
> framework so we can test more things in the future such as upcoming
> multi-buffer and metadata support for AF_XDP. The new programs just
> reuse the framework that all the other eBPF selftests use. The new
> feature is used to implement one new test that does XDP_DROP on every
> other packet. More tests using this will be added in future commits.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,01/15] selftests/xsk: print correct payload for packet dump
    https://git.kernel.org/bpf/bpf-next/c/2d0b2ae2871a
  - [bpf-next,v3,02/15] selftests/xsk: do not close unused file descriptors
    https://git.kernel.org/bpf/bpf-next/c/5adaf52776a4
  - [bpf-next,v3,03/15] selftests/xsk: submit correct number of frames in populate_fill_ring
    https://git.kernel.org/bpf/bpf-next/c/1e04f23bccf9
  - [bpf-next,v3,04/15] selftests/xsk: print correct error codes when exiting
    https://git.kernel.org/bpf/bpf-next/c/085dcccfb7d3
  - [bpf-next,v3,05/15] selftests/xsk: remove unused variable outstanding_tx
    https://git.kernel.org/bpf/bpf-next/c/a4ca62277b6a
  - [bpf-next,v3,06/15] selftests/xsk: add debug option for creating netdevs
    https://git.kernel.org/bpf/bpf-next/c/703bfd371013
  - [bpf-next,v3,07/15] selftests/xsk: replace asm acquire/release implementations
    https://git.kernel.org/bpf/bpf-next/c/efe620e5ba03
  - [bpf-next,v3,08/15] selftests/xsk: remove namespaces
    https://git.kernel.org/bpf/bpf-next/c/64aef77d750e
  - [bpf-next,v3,09/15] selftests/xsk: load and attach XDP program only once per mode
    https://git.kernel.org/bpf/bpf-next/c/aa61d81f397c
  - [bpf-next,v3,10/15] selftests/xsk: remove unnecessary code in control path
    https://git.kernel.org/bpf/bpf-next/c/6b3c0821caa4
  - [bpf-next,v3,11/15] selftests/xsk: get rid of built-in XDP program
    https://git.kernel.org/bpf/bpf-next/c/f0a249df1b07
  - [bpf-next,v3,12/15] selftests/xsk: add test when some packets are XDP_DROPed
    https://git.kernel.org/bpf/bpf-next/c/80bea9acabb7
  - [bpf-next,v3,13/15] selftests/xsk: merge dual and single thread dispatchers
    https://git.kernel.org/bpf/bpf-next/c/7f881984073a
  - [bpf-next,v3,14/15] selftests/xsk: automatically restore packet stream
    https://git.kernel.org/bpf/bpf-next/c/e67b2554f301
  - [bpf-next,v3,15/15] selftests/xsk: automatically switch XDP programs
    https://git.kernel.org/bpf/bpf-next/c/7d8319a7cc66

You are awesome, thank you!