This reverts commit d4c22d70d7253dd727c71484c58d504f6c630343.
There is no netdev queue left to wake after reverting
commit 1d6e569b7d0c ("tun/tap & vhost-net: avoid ptr_ring tail-drop
when a qdisc is present").
Signed-off-by: Simon Schippers <[email protected]>
---
drivers/net/tun.c | 61 ++++-------------------------------------------
1 file changed, 4 insertions(+), 57 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 39abc3078097..fed9dfdfcc3b 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -145,8 +145,6 @@ struct tun_file {
struct list_head next;
struct tun_struct *detached;
struct ptr_ring tx_ring;
- /* Protected by tx_ring.consumer_lock */
- int cons_cnt;
struct xdp_rxq_info xdp_rxq;
};
@@ -590,13 +588,8 @@ static void __tun_detach(struct tun_file *tfile, bool
clean)
rcu_assign_pointer(tun->tfiles[index],
tun->tfiles[tun->numqueues - 1]);
ntfile = rtnl_dereference(tun->tfiles[index]);
- spin_lock(&ntfile->tx_ring.consumer_lock);
ntfile->queue_index = index;
ntfile->xdp_rxq.queue_index = index;
- ntfile->cons_cnt = 0;
- if (__ptr_ring_empty(&ntfile->tx_ring))
- netif_wake_subqueue(tun->dev, index);
- spin_unlock(&ntfile->tx_ring.consumer_lock);
rcu_assign_pointer(tun->tfiles[tun->numqueues - 1],
NULL);
@@ -737,9 +730,6 @@ static int tun_attach(struct tun_struct *tun, struct file
*file,
goto out;
}
- spin_lock(&tfile->tx_ring.consumer_lock);
- tfile->cons_cnt = 0;
- spin_unlock(&tfile->tx_ring.consumer_lock);
tfile->queue_index = tun->numqueues;
tfile->socket.sk->sk_shutdown &= ~RCV_SHUTDOWN;
@@ -2126,46 +2116,13 @@ static ssize_t tun_put_user(struct tun_struct *tun,
return total;
}
-/* Callers must hold ring.consumer_lock */
-static void __tun_wake_queue(struct tun_struct *tun,
- struct tun_file *tfile, int consumed)
-{
- struct netdev_queue *txq = netdev_get_tx_queue(tun->dev,
- tfile->queue_index);
-
- /* Paired with smp_mb__after_atomic() in tun_net_xmit() */
- smp_mb();
- if (netif_tx_queue_stopped(txq)) {
- tfile->cons_cnt += consumed;
- if (tfile->cons_cnt >= tfile->tx_ring.size / 2 ||
- __ptr_ring_empty(&tfile->tx_ring)) {
- netif_tx_wake_queue(txq);
- tfile->cons_cnt = 0;
- }
- }
-}
-
-static void *tun_ring_consume(struct tun_struct *tun, struct tun_file *tfile)
-{
- void *ptr;
-
- spin_lock(&tfile->tx_ring.consumer_lock);
- ptr = __ptr_ring_consume(&tfile->tx_ring);
- if (ptr)
- __tun_wake_queue(tun, tfile, 1);
-
- spin_unlock(&tfile->tx_ring.consumer_lock);
- return ptr;
-}
-
-static void *tun_ring_recv(struct tun_struct *tun, struct tun_file *tfile,
- int noblock, int *err)
+static void *tun_ring_recv(struct tun_file *tfile, int noblock, int *err)
{
DECLARE_WAITQUEUE(wait, current);
void *ptr = NULL;
int error = 0;
- ptr = tun_ring_consume(tun, tfile);
+ ptr = ptr_ring_consume(&tfile->tx_ring);
if (ptr)
goto out;
if (noblock) {
@@ -2177,7 +2134,7 @@ static void *tun_ring_recv(struct tun_struct *tun, struct
tun_file *tfile,
while (1) {
set_current_state(TASK_INTERRUPTIBLE);
- ptr = tun_ring_consume(tun, tfile);
+ ptr = ptr_ring_consume(&tfile->tx_ring);
if (ptr)
break;
if (signal_pending(current)) {
@@ -2214,7 +2171,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct
tun_file *tfile,
if (!ptr) {
/* Read frames from ring */
- ptr = tun_ring_recv(tun, tfile, noblock, &err);
+ ptr = tun_ring_recv(tfile, noblock, &err);
if (!ptr)
return err;
}
@@ -3669,16 +3626,6 @@ static int tun_queue_resize(struct tun_struct *tun)
dev->tx_queue_len, GFP_KERNEL,
tun_ptr_free);
- if (!ret) {
- for (i = 0; i < tun->numqueues; i++) {
- tfile = rtnl_dereference(tun->tfiles[i]);
- spin_lock(&tfile->tx_ring.consumer_lock);
- netif_wake_subqueue(tun->dev, tfile->queue_index);
- tfile->cons_cnt = 0;
- spin_unlock(&tfile->tx_ring.consumer_lock);
- }
- }
-
kfree(rings);
return ret;
}
--
2.43.0