virtio-net: disable delayed refill when pausing rx
Subsystems (5)
v6 cover virtio-net: disable delayed refill when pausing rx
Hi everyone,
This only includes the selftest for virtio-net deadlock bug. The fix commit has been applied already.
Version 6 changes:
- Rebase on net-next and resolve conflicts
- Move the retry logic to xdp_helper
Version 5 changes:
- Refactor the selftest
Version 4 changes:
- Add force zerocopy mode to xdp_helper
- Make virtio_net selftest use force zerocopy mode
- Move virtio_net selftest to drivers/net/hw
Version 3 changes:
- Patch 1: refactor to avoid code duplication
Version 2 changes:
- Add selftest for deadlock scenario
Thanks,
Quang Minh.
Bui Quang Minh (4):
selftests: net: move xdp_helper to net/lib
selftests: net: add flag to force zerocopy mode in xdp_helper
selftests: net: retry when bind returns EBUSY in xdp_helper
selftests: net: add a virtio_net deadlock selftest
.../testing/selftests/drivers/net/.gitignore | 1 -
tools/testing/selftests/drivers/net/Makefile | 1 -
.../testing/selftests/drivers/net/hw/Makefile | 1 +
.../selftests/drivers/net/hw/xsk_reconfig.py | 60 +++++++++++++++++++
.../selftests/drivers/net/napi_id_helper.c | 2 +-
tools/testing/selftests/drivers/net/queues.py | 4 +-
tools/testing/selftests/net/lib/.gitignore | 1 +
tools/testing/selftests/net/lib/Makefile | 1 +
.../selftests/{drivers/net => net/lib}/ksft.h | 0
.../{drivers/net => net/lib}/xdp_helper.c | 39 +++++++++---
10 files changed, 98 insertions(+), 12 deletions(-)
create mode 100755 tools/testing/selftests/drivers/net/hw/xsk_reconfig.py
rename tools/testing/selftests/{drivers/net => net/lib}/ksft.h (100%)
rename tools/testing/selftests/{drivers/net => net/lib}/xdp_helper.c (78%)Signature · 1 line
2.43.0
PATCH v6 1/4 selftests: net: move xdp_helper to net/lib
Move xdp_helper to net/lib to make it easier for other selftests to use the helper.
---
tools/testing/selftests/drivers/net/.gitignore | 1 -
tools/testing/selftests/drivers/net/Makefile | 1 -
tools/testing/selftests/drivers/net/napi_id_helper.c | 2 +-
tools/testing/selftests/drivers/net/queues.py | 4 ++--
tools/testing/selftests/net/lib/.gitignore | 1 +
tools/testing/selftests/net/lib/Makefile | 1 +
tools/testing/selftests/{drivers/net => net/lib}/ksft.h | 0
tools/testing/selftests/{drivers/net => net/lib}/xdp_helper.c | 0
8 files changed, 5 insertions(+), 5 deletions(-)
rename tools/testing/selftests/{drivers/net => net/lib}/ksft.h (100%)
rename tools/testing/selftests/{drivers/net => net/lib}/xdp_helper.c (100%)tools/testing/selftests/drivers/net/.gitignore +0 -1
@@ -1,3 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only napi_id_helper -xdp_helper
tools/testing/selftests/drivers/net/Makefile +0 -1
@@ -8,7 +8,6 @@ TEST_INCLUDES := $(wildcard lib/py/*.py) \ TEST_GEN_FILES := \ napi_id_helper \ - xdp_helper \ # end of TEST_GEN_FILES TEST_PROGS := \
tools/testing/selftests/drivers/net/napi_id_helper.c +1 -1
@@ -8,7 +8,7 @@#include <arpa/inet.h> #include <sys/socket.h> -#include "ksft.h" +#include "../../net/lib/ksft.h" int main (int argc,char *argv[]) {
tools/testing/selftests/drivers/net/queues.py +2 -2
@@ -26,13 +26,13 @@ def nl_get_queues(cfg, nl, qtype='rx'): def check_xsk(cfg, nl, xdp_queue_id=0) -> None: # Probe for support - xdp = cmd(f'{cfg.test_dir / "xdp_helper"} - -', fail=False) + xdp = cmd(f'{cfg.net_lib_dir / "xdp_helper"} - -', fail=False) if xdp.ret == 255: raise KsftSkipEx('AF_XDP unsupported') elif xdp.ret > 0: raise KsftFailEx('unable to create AF_XDP socket') - with bkg(f'{cfg.test_dir / "xdp_helper"} {cfg.ifindex} {xdp_queue_id}', + with bkg(f'{cfg.net_lib_dir / "xdp_helper"} {cfg.ifindex} {xdp_queue_id}', ksft_wait=3): rx = tx = False
tools/testing/selftests/net/lib/.gitignore +1 -0
@@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only csum +xdp_helper
tools/testing/selftests/net/lib/Makefile +1 -0
@@ -10,6 +10,7 @@ TEST_FILES += ../../../../net/ynl TEST_GEN_FILES += csum TEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c)) +TEST_GEN_FILES += xdp_helper TEST_INCLUDES := $(wildcard py/*.py sh/*.sh)
tools/testing/selftests/net/lib/ksft.h renamed from tools/testing/selftests/drivers/net/ksft.h +0 -0
tools/testing/selftests/net/lib/xdp_helper.c renamed from tools/testing/selftests/drivers/net/xdp_helper.c +0 -0
Signature · 1 line
2.43.0
PATCH v6 2/4 selftests: net: add flag to force zerocopy mode in xdp_helper
In reply to Bui Quang MinhThis commit adds an optional -z flag to xdp_helper. When this flag is provided, the XDP socket binding is forced to be in zerocopy mode.
--- tools/testing/selftests/net/lib/xdp_helper.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
tools/testing/selftests/net/lib/xdp_helper.c +17 -2
@@ -17,6 +17,12 @@#define NUM_DESC (UMEM_SZ / 2048) +static void print_usage (const char *bin) +{ +fprintf (stderr,"Usage: %s ifindex queue_id [-z]\n\n" +"where:\n\t-z: force zerocopy mode" , bin); +} +/* this is a simple helper program that creates an XDP socket and does the * minimum necessary to get bind() to succeed. *
@@ -36,8 +42,8 @@ int main(int argc, char **argv)int sock_fd;int queue; -if (argc !=3 ) { -fprintf (stderr,"Usage: %s ifindex queue_id\n" , argv[0 ]); +if (argc !=3 && argc !=4 ) { +print_usage (argv[0 ]);return 1 ; }
@@ -87,6 +93,15 @@ int main(int argc, char **argv) sxdp.sxdp_queue_id = queue; sxdp.sxdp_flags =0 ; +if (argc >3 ) { +if (!strcmp (argv[3 ],"-z" )) { + sxdp.sxdp_flags =XDP_ZEROCOPY ; + }else { +print_usage (argv[0 ]); +return 1 ; + } + } +if (bind (sock_fd, (struct sockaddr *)&sxdp,sizeof (sxdp)) !=0 ) {munmap (umem_area,UMEM_SZ );perror ("bind failed" );
Signature · 1 line
2.43.0
PATCH v6 3/4 selftests: net: retry when bind returns EBUSY in xdp_helper
In reply to Bui Quang MinhWhen binding the XDP socket, we may get EBUSY because the deferred destructor of XDP socket in previous test has not been executed yet. If that is the case, just sleep and retry some times.
--- tools/testing/selftests/net/lib/xdp_helper.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
tools/testing/selftests/net/lib/xdp_helper.c +15 -5
@@ -38,6 +38,7 @@ int main(int argc, char **argv)struct sockaddr_xdp sxdp = {0 };int num_desc =NUM_DESC ;void *umem_area; +int retry =0 ;int ifindex;int sock_fd;int queue;
@@ -102,11 +103,20 @@ int main(int argc, char **argv) } } -if (bind (sock_fd, (struct sockaddr *)&sxdp,sizeof (sxdp)) !=0 ) { -munmap (umem_area,UMEM_SZ ); -perror ("bind failed" ); -close (sock_fd); -return 1 ; +while (1 ) { +if (bind (sock_fd, (struct sockaddr *)&sxdp,sizeof (sxdp)) ==0 ) +break ; + +if (errno ==EBUSY && retry <3 ) { + retry++; +sleep (1 ); +continue ; + }else { +perror ("bind failed" ); +munmap (umem_area,UMEM_SZ ); +close (sock_fd); +return 1 ; + } }ksft_ready ();
Signature · 1 line
2.43.0
PATCH v6 4/4 selftests: net: add a virtio_net deadlock selftest
In reply to Bui Quang MinhThe selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface.
--- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../selftests/drivers/net/hw/xsk_reconfig.py | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/hw/xsk_reconfig.py
tools/testing/selftests/drivers/net/hw/Makefile +1 -0
@@ -21,6 +21,7 @@ TEST_PROGS = \ rss_ctx.py \ rss_input_xfrm.py \ tso.py \ + xsk_reconfig.py \ # TEST_FILES := \
tools/testing/selftests/drivers/net/hw/xsk_reconfig.py new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 6 lines · Bui Quang Minh
Hi everyone,
This only includes the selftest for virtio-net deadlock bug. The fix commit has been applied already.
Quoted 44 lines
Version 6 changes:
- Rebase on net-next and resolve conflicts
- Move the retry logic toxdp_helperVersion 5 changes:
- Refactor the selftestVersion 4 changes:
- Add force zerocopy mode toxdp_helper
- Makevirtio_netselftest use force zerocopy mode
- Movevirtio_netselftest todrivers/net/hwVersion 3 changes:
- Patch 1: refactor to avoid code duplicationVersion 2 changes:
- Add selftest for deadlock scenarioThanks,
Quang Minh.Bui Quang Minh (4):
selftests: net: movexdp_helperto net/lib
selftests: net: add flag to force zerocopy mode inxdp_helper
selftests: net: retry when bind returns EBUSY inxdp_helper
selftests: net: add avirtio_netdeadlock selftest.../testing/selftests/drivers/net/.gitignore | 1 - tools/testing/selftests/drivers/net/Makefile | 1 - .../testing/selftests/drivers/net/hw/Makefile | 1 + .../selftests/drivers/net/hw/xsk_reconfig.py | 60 +++++++++++++++++++ .../selftests/drivers/net/napi_id_helper.c | 2 +- tools/testing/selftests/drivers/net/queues.py | 4 +- tools/testing/selftests/net/lib/.gitignore | 1 + tools/testing/selftests/net/lib/Makefile | 1 + .../selftests/{drivers/net => net/lib}/ksft.h | 0 .../{drivers/net => net/lib}/xdp_helper.c | 39 +++++++++--- 10 files changed, 98 insertions(+), 12 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/hw/xsk_reconfig.py rename tools/testing/selftests/{drivers/net => net/lib}/ksft.h (100%) rename tools/testing/selftests/{drivers/net => net/lib}/xdp_helper.c (78%)Signature · 1 line
2.43.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 25 Apr 2025 14:10:14 +0700 you wrote:
Hi everyone,
This only includes the selftest for virtio-net deadlock bug. The fix commit has been applied already.
[...]
Here is the summary with links:
- [v6,1/4] selftests: net: move xdp_helper to net/lib
https://git.kernel.org/netdev/net-next/c/59dd07db92c1 - [v6,2/4] selftests: net: add flag to force zerocopy mode in xdp_helper https://git.kernel.org/netdev/net-next/c/5d346179e709 - [v6,3/4] selftests: net: retry when bind returns EBUSY in xdp_helper https://git.kernel.org/netdev/net-next/c/b2b4555cf2a6 - [v6,4/4] selftests: net: add a virtio_net deadlock selftest https://git.kernel.org/netdev/net-next/c/c347fb0ff844
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html