History

Revert "tun/tap: add ptr_ring consume helper with netdev queue wakeup"

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").

Simon Schippers committed 3 months ago

Commit c3da92a1 parent 8f83be71 file · +4 −57Browse files

Unified · Split

drivers/net/tun.c+4−57
@@ -145,8 +145,6 @@ struct tun_file { · 144 unmodified lines
145145 struct list_head next;
146146 struct tun_struct *detached;
147147 struct ptr_ring tx_ring;
148− /* Protected by tx_ring.consumer_lock */
149− int cons_cnt;
150148 struct xdp_rxq_info xdp_rxq;
151149 };
152150
@@ -590,13 +588,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean) · 437 unmodified lines
590588 rcu_assign_pointer(tun->tfiles[index],
591589 tun->tfiles[tun->numqueues - 1]);
592590 ntfile = rtnl_dereference(tun->tfiles[index]);
593− spin_lock(&ntfile->tx_ring.consumer_lock);
594591 ntfile->queue_index = index;
595592 ntfile->xdp_rxq.queue_index = index;
596− ntfile->cons_cnt = 0;
597− if (__ptr_ring_empty(&ntfile->tx_ring))
598− netif_wake_subqueue(tun->dev, index);
599− spin_unlock(&ntfile->tx_ring.consumer_lock);
600593 rcu_assign_pointer(tun->tfiles[tun->numqueues - 1],
601594 NULL);
602595
@@ -737,9 +730,6 @@ static int tun_attach(struct tun_struct *tun, struct file *file, · 134 unmodified lines
737730 goto out;
738731 }
739732
740− spin_lock(&tfile->tx_ring.consumer_lock);
741− tfile->cons_cnt = 0;
742− spin_unlock(&tfile->tx_ring.consumer_lock);
743733 tfile->queue_index = tun->numqueues;
744734 tfile->socket.sk->sk_shutdown &= ~RCV_SHUTDOWN;
745735
@@ -2126,46 +2116,13 @@ done: · 1380 unmodified lines
21262116 return total;
21272117 }
21282118
2129−/* Callers must hold ring.consumer_lock */
2130−static void __tun_wake_queue(struct tun_struct *tun,
2131− struct tun_file *tfile, int consumed)
2132−{
2133− struct netdev_queue *txq = netdev_get_tx_queue(tun->dev,
2134− tfile->queue_index);
2135−
2136− /* Paired with smp_mb__after_atomic() in tun_net_xmit() */
2137− smp_mb();
2138− if (netif_tx_queue_stopped(txq)) {
2139− tfile->cons_cnt += consumed;
2140− if (tfile->cons_cnt >= tfile->tx_ring.size / 2 ||
2141− __ptr_ring_empty(&tfile->tx_ring)) {
2142− netif_tx_wake_queue(txq);
2143− tfile->cons_cnt = 0;
2144− }
2145− }
2146−}
2147−
2148−static void *tun_ring_consume(struct tun_struct *tun, struct tun_file *tfile)
2149−{
2150− void *ptr;
2151−
2152− spin_lock(&tfile->tx_ring.consumer_lock);
2153− ptr = __ptr_ring_consume(&tfile->tx_ring);
2154− if (ptr)
2155− __tun_wake_queue(tun, tfile, 1);
2156−
2157− spin_unlock(&tfile->tx_ring.consumer_lock);
2158− return ptr;
2159−}
2160−
2161−static void *tun_ring_recv(struct tun_struct *tun, struct tun_file *tfile,
2162− int noblock, int *err)
2119+static void *tun_ring_recv(struct tun_file *tfile, int noblock, int *err)
21632120 {
21642121 DECLARE_WAITQUEUE(wait, current);
21652122 void *ptr = NULL;
21662123 int error = 0;
21672124
2168− ptr = tun_ring_consume(tun, tfile);
2125+ ptr = ptr_ring_consume(&tfile->tx_ring);
21692126 if (ptr)
21702127 goto out;
21712128 if (noblock) {
@@ -2177,7 +2134,7 @@ static void *tun_ring_recv(struct tun_struct *tun, struct tun_file *tfile, · 5 unmodified lines
21772134
21782135 while (1) {
21792136 set_current_state(TASK_INTERRUPTIBLE);
2180− ptr = tun_ring_consume(tun, tfile);
2137+ ptr = ptr_ring_consume(&tfile->tx_ring);
21812138 if (ptr)
21822139 break;
21832140 if (signal_pending(current)) {
@@ -2214,7 +2171,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile, · 30 unmodified lines
22142171
22152172 if (!ptr) {
22162173 /* Read frames from ring */
2217− ptr = tun_ring_recv(tun, tfile, noblock, &err);
2174+ ptr = tun_ring_recv(tfile, noblock, &err);
22182175 if (!ptr)
22192176 return err;
22202177 }
@@ -3669,16 +3626,6 @@ static int tun_queue_resize(struct tun_struct *tun) · 1448 unmodified lines
36693626 dev->tx_queue_len, GFP_KERNEL,
36703627 tun_ptr_free);
36713628
3672− if (!ret) {
3673− for (i = 0; i < tun->numqueues; i++) {
3674− tfile = rtnl_dereference(tun->tfiles[i]);
3675− spin_lock(&tfile->tx_ring.consumer_lock);
3676− netif_wake_subqueue(tun->dev, tfile->queue_index);
3677− tfile->cons_cnt = 0;
3678− spin_unlock(&tfile->tx_ring.consumer_lock);
3679− }
3680− }
3681−
36823629 kfree(rings);
36833630 return ret;
36843631 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t