From: Bui Quang Minh <minhquangbui99@gmail.com>
To: virtualization@lists.linux.dev
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, "Bui Quang Minh" <minhquangbui99@gmail.com>
Subject: [PATCH v3 0/3] virtio-net: disable delayed refill when pausing rx
Date: Tue, 15 Apr 2025 14:43:38 +0700 [thread overview]
Message-ID: <20250415074341.12461-1-minhquangbui99@gmail.com> (raw)
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 3 changes:
- Patch 1: refactor to avoid code duplication
Version 2 changes:
- Add selftest for deadlock scenario
Thanks,
Quang Minh.
Bui Quang Minh (3):
virtio-net: disable delayed refill when pausing rx
selftests: net: move xdp_helper to net/lib
selftests: net: add a virtio_net deadlock selftest
drivers/net/virtio_net.c | 69 +++++++++++++++----
tools/testing/selftests/Makefile | 2 +-
tools/testing/selftests/drivers/net/Makefile | 2 -
tools/testing/selftests/drivers/net/queues.py | 4 +-
.../selftests/drivers/net/virtio_net/Makefile | 2 +
.../selftests/drivers/net/virtio_net/config | 1 +
.../drivers/net/virtio_net/lib/py/__init__.py | 16 +++++
.../drivers/net/virtio_net/xsk_pool.py | 52 ++++++++++++++
tools/testing/selftests/net/lib/.gitignore | 1 +
tools/testing/selftests/net/lib/Makefile | 1 +
.../{drivers/net => net/lib}/xdp_helper.c | 0
11 files changed, 133 insertions(+), 17 deletions(-)
create mode 100644 tools/testing/selftests/drivers/net/virtio_net/lib/py/__init__.py
create mode 100755 tools/testing/selftests/drivers/net/virtio_net/xsk_pool.py
rename tools/testing/selftests/{drivers/net => net/lib}/xdp_helper.c (100%)
--
2.43.0
next reply other threads:[~2025-04-15 7:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 7:43 Bui Quang Minh [this message]
2025-04-15 7:43 ` [PATCH v3 1/3] virtio-net: disable delayed refill when pausing rx Bui Quang Minh
2025-04-15 13:19 ` Michael S. Tsirkin
2025-04-15 7:43 ` [PATCH v3 2/3] selftests: net: move xdp_helper to net/lib Bui Quang Minh
2025-04-15 7:43 ` [PATCH v3 3/3] selftests: net: add a virtio_net deadlock selftest Bui Quang Minh
2025-04-16 4:27 ` Jakub Kicinski
2025-04-16 6:54 ` Bui Quang Minh
2025-04-16 7:46 ` Jason Wang
2025-04-16 9:00 ` Bui Quang Minh
2025-04-17 0:08 ` Jakub Kicinski
2025-04-15 14:04 ` [PATCH v3 0/3] virtio-net: disable delayed refill when pausing rx Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250415074341.12461-1-minhquangbui99@gmail.com \
--to=minhquangbui99@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=hawk@kernel.org \
--cc=jasowang@redhat.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox