From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, axboe@kernel.dk, netdev@vger.kernel.org
Subject: [PATCH io_uring for-6.18 14/20] io_uring/zcrx: protect netdev with pp_lock
Date: Tue, 16 Sep 2025 15:27:57 +0100 [thread overview]
Message-ID: <a1c84a5c5e357274566b63f0d7bfcbd6b839488e.1758030357.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1758030357.git.asml.silence@gmail.com>
Remove ifq->lock and reuse pp_lock to protect the netdev pointer.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 23 +++++++++++------------
io_uring/zcrx.h | 1 -
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 0deb41b74b7c..6a5b6f32edc3 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -476,7 +476,6 @@ static struct io_zcrx_ifq *io_zcrx_ifq_alloc(struct io_ring_ctx *ctx)
ifq->if_rxq = -1;
ifq->ctx = ctx;
- spin_lock_init(&ifq->lock);
spin_lock_init(&ifq->rq_lock);
mutex_init(&ifq->pp_lock);
return ifq;
@@ -484,12 +483,12 @@ static struct io_zcrx_ifq *io_zcrx_ifq_alloc(struct io_ring_ctx *ctx)
static void io_zcrx_drop_netdev(struct io_zcrx_ifq *ifq)
{
- spin_lock(&ifq->lock);
- if (ifq->netdev) {
- netdev_put(ifq->netdev, &ifq->netdev_tracker);
- ifq->netdev = NULL;
- }
- spin_unlock(&ifq->lock);
+ guard(mutex)(&ifq->pp_lock);
+
+ if (!ifq->netdev)
+ return;
+ netdev_put(ifq->netdev, &ifq->netdev_tracker);
+ ifq->netdev = NULL;
}
static void io_close_queue(struct io_zcrx_ifq *ifq)
@@ -504,11 +503,11 @@ static void io_close_queue(struct io_zcrx_ifq *ifq)
if (ifq->if_rxq == -1)
return;
- spin_lock(&ifq->lock);
- netdev = ifq->netdev;
- netdev_tracker = ifq->netdev_tracker;
- ifq->netdev = NULL;
- spin_unlock(&ifq->lock);
+ scoped_guard(mutex, &ifq->pp_lock) {
+ netdev = ifq->netdev;
+ netdev_tracker = ifq->netdev_tracker;
+ ifq->netdev = NULL;
+ }
if (netdev) {
net_mp_close_rxq(netdev, ifq->if_rxq, &p);
diff --git a/io_uring/zcrx.h b/io_uring/zcrx.h
index 3f89a34e5282..a48871b5adad 100644
--- a/io_uring/zcrx.h
+++ b/io_uring/zcrx.h
@@ -53,7 +53,6 @@ struct io_zcrx_ifq {
struct device *dev;
struct net_device *netdev;
netdevice_tracker netdev_tracker;
- spinlock_t lock;
/*
* Page pool and net configuration lock, can be taken deeper in the
--
2.49.0
next prev parent reply other threads:[~2025-09-16 14:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 14:27 [PATCH io_uring for-6.18 00/20] zcrx for-6.18 updates Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 01/20] io_uring/zcrx: improve rqe cache alignment Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 02/20] io_uring/zcrx: replace memchar_inv with is_zero Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 03/20] io_uring/zcrx: use page_pool_unref_and_test() Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 04/20] io_uring/zcrx: remove extra io_zcrx_drop_netdev Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 05/20] io_uring/zcrx: don't pass slot to io_zcrx_create_area Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 06/20] io_uring/zcrx: move area reg checks into io_import_area Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 07/20] io_uring/zcrx: check all niovs filled with dma addresses Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 08/20] io_uring/zcrx: pass ifq to io_zcrx_alloc_fallback() Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 09/20] io_uring/zcrx: deduplicate area mapping Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 10/20] io_uring/zcrx: remove dmabuf_offset Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 11/20] io_uring/zcrx: set sgt for umem area Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 12/20] io_uring/zcrx: make niov size variable Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 13/20] io_uring/zcrx: rename dma lock Pavel Begunkov
2025-09-16 14:27 ` Pavel Begunkov [this message]
2025-09-16 14:27 ` [PATCH io_uring for-6.18 15/20] io_uring/zcrx: reduce netmem scope in refill Pavel Begunkov
2025-09-16 14:27 ` [PATCH io_uring for-6.18 16/20] io_uring/zcrx: use guards for the refill lock Pavel Begunkov
2025-09-16 14:28 ` [PATCH io_uring for-6.18 17/20] io_uring/zcrx: don't adjust free cache space Pavel Begunkov
2025-09-16 14:28 ` [PATCH io_uring for-6.18 18/20] io_uring/zcrx: introduce io_parse_rqe() Pavel Begunkov
2025-09-16 14:28 ` [PATCH io_uring for-6.18 19/20] io_uring/zcrx: allow synchronous buffer return Pavel Begunkov
2025-09-16 14:28 ` [PATCH io_uring for-6.18 20/20] io_uring/zcrx: account niov arrays to cgroup Pavel Begunkov
2025-09-16 18:37 ` [PATCH io_uring for-6.18 00/20] zcrx for-6.18 updates Jens Axboe
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=a1c84a5c5e357274566b63f0d7bfcbd6b839488e.1758030357.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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