Skip to content

Commit 20dda44

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: protect netdev with pp_lock
Remove ifq->lock and reuse pp_lock to protect the netdev pointer. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 4f602f3 commit 20dda44

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

io_uring/zcrx.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -476,20 +476,19 @@ static struct io_zcrx_ifq *io_zcrx_ifq_alloc(struct io_ring_ctx *ctx)
476476

477477
ifq->if_rxq = -1;
478478
ifq->ctx = ctx;
479-
spin_lock_init(&ifq->lock);
480479
spin_lock_init(&ifq->rq_lock);
481480
mutex_init(&ifq->pp_lock);
482481
return ifq;
483482
}
484483

485484
static void io_zcrx_drop_netdev(struct io_zcrx_ifq *ifq)
486485
{
487-
spin_lock(&ifq->lock);
488-
if (ifq->netdev) {
489-
netdev_put(ifq->netdev, &ifq->netdev_tracker);
490-
ifq->netdev = NULL;
491-
}
492-
spin_unlock(&ifq->lock);
486+
guard(mutex)(&ifq->pp_lock);
487+
488+
if (!ifq->netdev)
489+
return;
490+
netdev_put(ifq->netdev, &ifq->netdev_tracker);
491+
ifq->netdev = NULL;
493492
}
494493

495494
static void io_close_queue(struct io_zcrx_ifq *ifq)
@@ -504,11 +503,11 @@ static void io_close_queue(struct io_zcrx_ifq *ifq)
504503
if (ifq->if_rxq == -1)
505504
return;
506505

507-
spin_lock(&ifq->lock);
508-
netdev = ifq->netdev;
509-
netdev_tracker = ifq->netdev_tracker;
510-
ifq->netdev = NULL;
511-
spin_unlock(&ifq->lock);
506+
scoped_guard(mutex, &ifq->pp_lock) {
507+
netdev = ifq->netdev;
508+
netdev_tracker = ifq->netdev_tracker;
509+
ifq->netdev = NULL;
510+
}
512511

513512
if (netdev) {
514513
net_mp_close_rxq(netdev, ifq->if_rxq, &p);

io_uring/zcrx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ struct io_zcrx_ifq {
5353
struct device *dev;
5454
struct net_device *netdev;
5555
netdevice_tracker netdev_tracker;
56-
spinlock_t lock;
5756

5857
/*
5958
* Page pool and net configuration lock, can be taken deeper in the

0 commit comments

Comments
 (0)