netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] virtio-net: disable delayed refill when pausing rx
@ 2025-04-17  7:28 Bui Quang Minh
  2025-04-17  7:28 ` [PATCH v4 1/4] " Bui Quang Minh
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Bui Quang Minh @ 2025-04-17  7:28 UTC (permalink / raw)
  To: virtualization
  Cc: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, Andrew Lunn,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
	Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
	Eugenio Pérez, David S. Miller, netdev, linux-kernel, bpf,
	Bui Quang Minh

Hi everyone,

This series tries to fix a deadlock in virtio-net when binding/unbinding
XDP program, XDP socket or resizing the rx queue.

When pausing rx (e.g. set up xdp, xsk pool, rx resize), we call
napi_disable() on the receive queue's napi. In delayed refill_work, it
also calls napi_disable() on the receive queue's napi. When
napi_disable() is called on an already disabled napi, it will sleep in
napi_disable_locked while still holding the netdev_lock. As a result,
later napi_enable gets stuck too as it cannot acquire the netdev_lock.
This leads to refill_work and the pause-then-resume tx are stuck
altogether.

This scenario can be reproducible by binding a XDP socket to virtio-net
interface without setting up the fill ring. As a result, try_fill_recv
will fail until the fill ring is set up and refill_work is scheduled.

This fix adds virtnet_rx_(pause/resume)_all helpers and fixes up the
virtnet_rx_resume to disable future and cancel all inflights delayed
refill_work before calling napi_disable() to pause the rx.

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):
  virtio-net: disable delayed refill when pausing rx
  selftests: net: move xdp_helper to net/lib
  selftests: net: add flag to force zerocopy mode in xdp_helper
  selftests: net: add a virtio_net deadlock selftest

 drivers/net/virtio_net.c                      | 69 +++++++++++++++----
 tools/testing/selftests/drivers/net/Makefile  |  2 -
 .../testing/selftests/drivers/net/hw/Makefile |  1 +
 .../selftests/drivers/net/hw/virtio_net.py    | 65 +++++++++++++++++
 tools/testing/selftests/drivers/net/queues.py |  4 +-
 tools/testing/selftests/net/lib/.gitignore    |  1 +
 tools/testing/selftests/net/lib/Makefile      |  1 +
 .../{drivers/net => net/lib}/xdp_helper.c     | 13 +++-
 8 files changed, 138 insertions(+), 18 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/hw/virtio_net.py
 rename tools/testing/selftests/{drivers/net => net/lib}/xdp_helper.c (90%)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-04-24 22:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17  7:28 [PATCH v4 0/4] virtio-net: disable delayed refill when pausing rx Bui Quang Minh
2025-04-17  7:28 ` [PATCH v4 1/4] " Bui Quang Minh
2025-04-21  3:03   ` Jason Wang
2025-04-17  7:28 ` [PATCH v4 2/4] selftests: net: move xdp_helper to net/lib Bui Quang Minh
2025-04-17  7:28 ` [PATCH v4 3/4] selftests: net: add flag to force zerocopy mode in xdp_helper Bui Quang Minh
2025-04-23  1:34   ` Jakub Kicinski
2025-04-17  7:28 ` [PATCH v4 4/4] selftests: net: add a virtio_net deadlock selftest Bui Quang Minh
2025-04-23  1:41   ` Jakub Kicinski
2025-04-23 15:20     ` Bui Quang Minh
2025-04-23 22:23       ` Jakub Kicinski
2025-04-24 10:33         ` Bui Quang Minh
2025-04-24 22:07           ` Jakub Kicinski
2025-04-23  1:50 ` [PATCH v4 0/4] virtio-net: disable delayed refill when pausing rx patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).