Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Pavel Begunkov and committed by
Jens Axboe
20dda449 4f602f31

+11 -13
+11 -12
io_uring/zcrx.c
··· 476 476 477 477 ifq->if_rxq = -1; 478 478 ifq->ctx = ctx; 479 - spin_lock_init(&ifq->lock); 480 479 spin_lock_init(&ifq->rq_lock); 481 480 mutex_init(&ifq->pp_lock); 482 481 return ifq; ··· 483 484 484 485 static void io_zcrx_drop_netdev(struct io_zcrx_ifq *ifq) 485 486 { 486 - spin_lock(&ifq->lock); 487 - if (ifq->netdev) { 488 - netdev_put(ifq->netdev, &ifq->netdev_tracker); 489 - ifq->netdev = NULL; 490 - } 491 - spin_unlock(&ifq->lock); 487 + guard(mutex)(&ifq->pp_lock); 488 + 489 + if (!ifq->netdev) 490 + return; 491 + netdev_put(ifq->netdev, &ifq->netdev_tracker); 492 + ifq->netdev = NULL; 492 493 } 493 494 494 495 static void io_close_queue(struct io_zcrx_ifq *ifq) ··· 503 504 if (ifq->if_rxq == -1) 504 505 return; 505 506 506 - spin_lock(&ifq->lock); 507 - netdev = ifq->netdev; 508 - netdev_tracker = ifq->netdev_tracker; 509 - ifq->netdev = NULL; 510 - spin_unlock(&ifq->lock); 507 + scoped_guard(mutex, &ifq->pp_lock) { 508 + netdev = ifq->netdev; 509 + netdev_tracker = ifq->netdev_tracker; 510 + ifq->netdev = NULL; 511 + } 511 512 512 513 if (netdev) { 513 514 net_mp_close_rxq(netdev, ifq->if_rxq, &p);
-1
io_uring/zcrx.h
··· 53 53 struct device *dev; 54 54 struct net_device *netdev; 55 55 netdevice_tracker netdev_tracker; 56 - spinlock_t lock; 57 56 58 57 /* 59 58 * Page pool and net configuration lock, can be taken deeper in the